URGENT: False undeclared identifiers?

Here I am, working on a project for C++ and I am almost finished, but for some reason, one single line out of the entire code apparently decided to give me the finger and make the compiler come back with an undeclared identifier error that should not be happening.

Here are the offending lines.

1
2
3
4
5
6
int i = 0;
while(i < maxCells && extract >> idArray[i] >> storeArray[i] >> qtyArray[i])
{
	i++;
	count++;
}


I dunno what is causing this, but it's a real pain in the backside that needs fixing.
Last edited on
You're lacking semicolons after the two postfix increment (why not prefix?) statements and we can only be sure that i was declared.
maxCells and the Arrays, and extract (which is an if-stream) are declared earlier in the program, these three lines so far are the only ones giving this error, and are inside of a function called loadArrays, and appear to give the error without a logical explanation.

For the specific line, the compiler only lists line 58 (which is the second line of code here) as the offending line, and it gives the error four times (one for each i) even though it has been declare already.
Last edited on
maxCells and the Arrays, and extract (which is an if-stream) are declared earlier in the program, these three lines so far are the only ones giving this error, and are inside of a function called loadArrays,


And are they visible within the scope of the function?
Well, first of all, it's strange having that expression to the rhs of && on Line 2.
After all, istream's operator>> returns istream& which is always going to be non-false.
Have you tried moving that chunk inside the loop after Line 3?
Well, first of all, it's strange having that expression to the rhs of && on Line 2.
After all, istream's operator>> returns istream& which is always going to be non-false.

No, that's perfectly fine. A stream, when used as a boolean, will evaluate to false if it goes into a failure or eof state, and true otherwise.
I'm at a loss - maybe you need to post the surrounding code?
Does it compile fine if you comment out this section?
Maybe you have hidden invisible control characters in your textfile?
(Just throwing ideas out)
Last edited on
Topic archived. No new replies allowed.