Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) I guess you found it because you posted here :)
2) don't know
3) People with green squares can give you at least 1 rep point. People with black give 0 because they don't have enough posts yet, people with red or yellow have negative rep.
4) LOL :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It worked in my test because I deleted that last line not because of the other stuff I commented out. If that last line is supposed to have only one character = then it is better to read the file one character at a time until eof, something line StuXYZ previously posted.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have a problem at the last line of your input file.

You read while(partin >> charInput >> numInput) and you have just = on the list line so it reads into charInput and then waits and waits.....

You need to read the char and then the number, and check the status of the file in between.

That's not the problem. The problem seems to be in the last line of that file where the number is missing.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I commented out the queue.cpp include and associated objects, leaving only the file reading. Your problem is NOT in file reading because that works ok. That means the problem is in the code you did not post.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The code looks ok, can you post a few lines of that file?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Aren't those manuals normally reserved for teachers and educational instutions???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As for the actual code -- I wouldn't clear the screen so that the user can see what he/she did wrong. If you erase it the user may not remember what he did and repeat the error. IMO it is better to just print a couple newlines and leave the rest on the screen.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to tell cout how many decimals you want it to print: example

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    double x = 12345.7890;

    cout << fixed << setprecision(2) << x << "\n";
    cout << fixed << setprecision(3) << x << "\n";
    cout << fixed << setprecision(4) << x << "\n";
}

output

12345.79
12345.789
12345.7890
Press any key to continue . . .
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

or something like this

bool done = false;
while( !done )
{
             //Your code before the if.

             if (cy>0 && cm>0 && cd>0 && by>0 && bm>0 && bd>0)
            {
                    done = true;
            } 
            else
            {
                    clrscr();
                    printf("Enter correct date.")
            }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not that I know of -- but then I don't know everything either :) Read through those google links to see if you can find one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Comatose commented: Hahahaha :) +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OMG that has to be an extremely sloooooow program. A more efficient way would be to keep the times in the vectorl so that they can easily be referenced, maybe something like this:

struct files
{
     std::string filename;
     FILETIME  tm;
};

vector<files> list;

line 18: are you sure that is how its coded in your program? std::vector &inFiles doesn't make any sense.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if( kbSize == 2000 || 3000 || 4000 || 5000);

There are several things wrong with the above statement:
1) the semicolon at the end makes it a do-nothing statement.
2) it should be formatted like this: if( kbSize == 2000 || kbSize == 3000 || kbSize == 4000 || kbSize == 5000)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

check the spelling -- capatilization is important

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fstream us standard c++ class so it works the same on all operating systems that support them.

WritePrivateProfileString() does nothing more than rewrite the file with the new string in the form <tag name>=<value> . You can do this yourself with ofstream.

ofstream out("filename.ini");
out << "[MySectionName]\n"; // beginning of section
out << "LName=" << lname << "\n";
out << "FName=" << fname << "\n";
...
<etc. etc. for all fields
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
std::vector<std::ofstream*> fileList;
            fileList.resize (argc - 1);
            for(int i = 1; i < argc; ++i)
            {
                  fileList[i] = new std::ofsteam(argv[i]);
            }

All taking about the line fileList[i] = new std::ofsteam(argv[i]); From what I've gathered from google this happens when you forget to #include stuff but I have ofstream and vector in my includes.

That is correct -- I didn't post a complete program. You will have to add the #include's. If you did include those and still have compile problems you need to post complete code, not just partial.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Also, lines 13 and 14: why not just output it as a string with one simple line: cout << student[i] << "\n"; . The j loop is completly unnecessary.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 32 and 33: That doesn't work because the string is located in read-only memory, and attempting to write to that memory will most likely fail. Correction: This puts the string in writeable memory. char BlankPattern[]="###############"; line 39: The above doesn't work either because you can not return a character array from a function. So your only choice is to allocate memory. Note that the calling function will have to call delete[] to properly destroy this string.

char* BlankPattern = new char[16];
    // copy at most 15 characters to BlankPattern
    // if [b]string[/b] is longer than that, then the remaining
    // characters are ignored.
    strncpy(BlankPattern, string, 15);
    // now fill remaining positions with '#'
    for(int n = strlen(string); i < 15; n++)
        BlankPattern[n] = '#';
    BlankPattern[15] = 0;
    return BlankPattern;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, StuXYZ is correct about using pointers

int main (int argc, char** argv)
{
    std::vector<std::ofstream*> fileList;
    fileList.resize (argc - 1);
    for(int i = 1; i < argc; ++i)
    {
        fileList[i] = new ofstream(argv[i]);
    }
}

If you only have to write something once to each of those file then use just one ofstream object, open each file, write data, close file, continue the loop.

Note: std::out is NOT needed for ofstream because that is the default behavior.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

C++ also supports malloc(), although you are right in that new is preferrable.

For typecasing malloc(), please read this. Need to include stdlib.h to correct the warning, not do a typecast.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>warning: assignment makes pointer from integer without a cast
You are compiling it as C++. Change the file extension to *.c and you will not get that warning.

you still have not fixed the error on line 8. int i, j, **randno, arraywidth, arrayheight; Go back and re-read the code I previously posted. Your code is still incorrect.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>// TYPECAST THE OUTPUT OF MALLOC

Not in C language. C++ requires the typecase but C does not.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you probably want vector<ofstream> fileList; Now all you have to do is loop through the names and open the files, something like this:

vector<ofstream fileList;
fileList.resize(argc-1); 
for(int i = 1; i < argc; i++)
{
    fileList[i].open(argv[i]);
}

Now to write something to all the files just use another loop similar to the above.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>lint 9: *randno[j],

That is not leagal way to declare an array because i and j must be constants. What you have are two uninitialized integers.

If you want to declare a two-dimensional array of integers but you don't know how many rows and columns then declare it with a double star like this: int ** randno = 0; Now, to allocate both dimensions

arraysize = 100; // number of rows
randno = malloc(arraysize * sizeof(int *)); // allocate array of pointers
//
// now allocate the columns for each row
for(i = 0; i < arraysize; i++)
{
    randno[i] = malloc(10 * sizeof(int)); // each row has 10 integers
}
Alibeg commented: Straight in center +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

wxWidgets and OpenGL -- google for them.

Salem commented: cool efficiency +27
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first problem is line 25 -- count the ( and ) pairs. line 28 and 31 have the same problem if ( (hours<3) && (hours>0) )

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I did what you said and changed the constructor so it takes no values but i still get errors

Also i need the constructor to take an initial value

you can have as many constructors as you like.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>SavingsAccount.hpp(9) : error C2512: 'Account' : no appropiate default constructor available

That means Account needs a constructor that takes no parameters.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) open the file

FILE* fp = fopen("myfile.txt");

2) use fprintf()

fprintf(fp,"%x", 123);

How difficult was that??

But this is c++, so you should be using the functions in <fstream>

#include <fstream>
using namespace std;

int main()
{
     ofstream out("myfile.txt");
     out << hex << 123 << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

allocate and top the string first then reset pointer a

char* temp  = new char[n];
    char* p = temp;
    memset(temp,' ',n);
    temp[n-1] = 0; //null  terminate
    memcpy(temp, a, strlen(a));
    a = temp;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Learn to use your compiler's debugger and single-step through your program to see what is happening. The problem could be in whitelist() function or somewhere before that function is called. Its impossible for anyone to analyze your program without seeing the code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If the classes can be plugged into other projercts without change then make a shared library out of them. That way there is only one set of source files and the projects all link with the same library.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>everytime pin or checks is not a null string it throws a GPF.

>>checks and pin are strings

Do you mean std::string declared in <string> header file? Those are not null-terminated strings at all but c++ class.

Post the function prototype for whitelist(checks, pin, wkbool, wqbool, enpassant)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That is what i wanted to do, i want to use the same variables , but i don't know how to do it exactly

I just told you how. Add the two variables as parameters to the function then pass them on line 37, just like you would pass a variable to any other standard function. And don't forget to change the function declaration in the class iteself. Findlly, delete b and k on line 23.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are looking at the wrong line -- see line 26 in the code you posted above, which may or may not be the same line in your compiler.

The variables b and k declared on line 31 are not the same as the variables declared on line 23. If you want to use the variables declared in main() then you will have to pass them as parameters to Bata() function. double Gama::Beta(int b, int k) Another option is to make b and k members of the class.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The variable k is being used without being intialized
what does this meen?

Look at like 26: what is the value of variables b and k? Answer: their value is just some random number that happens to be in the memory location when the function started. You need to set b and k to some number before that loop starts.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is wrong with it?

line 37: geta() is a function -- you need to add the ()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to be careful about string literals such as what you just posted above ^^^. String literals are (normally) stored in read-only memory so they can't be changed. What you posted originally is correect because the array isn't a string literal but a character array: char p[] = " smith";char*a = p; You can pass that to your trimLeft() function but not this: char *p = " smith";

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want to set all elements to 0 then you can use memset(). Microsoft compilers implement that function in assembly because the chip has an instruction that will do it, and that is about as efficient as you can get. I don't know how other compilers implement it.

Also use the = {0} when declaring the array. int myarray[255] = {0};

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> But what i fail to understand is that when i'm passing the address of array and incrementing the pointer why is it not having as the same effect as the code that you have given

Because you did not pass the address of the pointer -- all you did was pass the address of the start of the character array, which is not the same thing. Look closely at the & symbol in the trimLeft() function declaration -- that is a reference to a pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A buffer is normally just a block of memory where things can be stored in RAM. A stream is something that lets you store things on disk, send across to other computers such as the internet, serial port, UCB, etc. streams often use buffers to optimize transmission speed. For example instead of writing data directly to disk the stream (e.g. ofstream object) might store it in a buffer and write to disk when either the buffer is full or when there is available time such as while the program is waiting for keyboard input.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

trimleft() does nothing. After finding the last space you need to shift all remaining characters left. memmove() will do that for you, or you can do it yourself using two pointers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This has been reported before, but I can't find the thread at the moment. As I recall (maybe wrongly) that comment is intentional.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And how do you think DaniWeb should read your mind?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

i have to read two text file
"textfile.txt" and "textfile2.txt"

it only reads "textfile.txt"

how to join the two text and read it.

Open both text files and just read each of them. Only you can answer your question because we have no idea what the hell you are talking about.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you could do something like this:

fscanf(fp,"%s%s%s", List[i].ID, List[i].YR, List[i].lname);
  // get the first name separately because it may be composed of 
  // two or more names with spaces, so fscanf() will not work with this.
fgets(List[i].fname, sizeof(List[i].fname, fp);

Of course you will have to put the above in a loop after opening the file for reading.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Don't know the answer to your question until I know the contents of the text file. Without that knowledge, generally I would use fgets() to read a line, then parse it into its individual parts into the structure.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>for (i=0;i<=(this->Picture->Width/(3*this->cellsize));i++)
>> for (ii=0;ii<=(this->Picture->Height/(4*this->cellsize));ii++)

Don't you realize the program has to make all those calculations on every loop iteration? That's very very time consuming since the value of Width and cellsize do not change during those loops. It would be much more efficient to just calculate them once above/outside those two loops and use the temp variables inside the loop.

As for your problem: I suspect memory corruption somewhere else. Your program has probably done something to corrupt stack, and the problem just happens to appear on the line you marked. My suggestion is to start commenting stuff out until the problem disappears.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

copy the string one character at a time into another variable that is long enough to hold the extra characters. When an '\' is encountered just copy two of them.

But I have to question your reason for doing that. When you type a path from the keyboard into a variable you don't need the couble '\' characters. They are only needed when you use string literals in your program because the compiler has to interpret the characters.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Try a slightly different algorithm

void voorkomentellen ( vector<int> getallen , vector<int>& getelde_rij, vector<int>& voorkomen )
{
	unsigned int i, teller; 
	int getal1, getal2, count=1;
	getal1 = getallen[0];
	for (i = 1; i < getallen.size( ); i++)
	{
		getal2 = getallen[i];
		if (getal1 == getal2)
		{
			count++;
		}
		else
		{
			getelde_rij.push_back(getal1);
			voorkomen.push_back(count);
			count=1;
                           getal1 = getal2;                       
		}
	}
}