Quote:
Originally Posted by weaknessforcats
What's haappening is that one of your inputfile>> is failing.
The >> operator fetches data into the variable you specify. It that variable is the wrong type (like trying to fetch a 1 so a char or an A to an int), the >> operator sets a fail bit.
This fail bit is the first things check by the >> operator itself. SO on the next inputfile>> the fail bit is on so the >> does nothing and returns.
The effect is that after the failure, all of the >> operators in your program appear to not work.
You have to
1)test every >> operator to make sure the fail bit is off:
-
inputfile>>data;
-
if (inputfile.fail() == true)
-
{
-
//Big problem
-
}
-
//OK to continue
-
If the fail bit is on, you can reset it by calling inputfile.clear(). However, the data that caused the error is still in the inout stream and will have to be dealt with.
Remember, the >> assumes you know ahead of time what data is being fetched AND that the data elements are separated from each other by whitespace. If this is not the case, then you can't use the >> operator.
First of all, thank you very much for the reply.
You know, I'm starting to think that either Borland at all or just my version specifically has a very bad compiler.
Yesterday i left this function as it was, and today when I opened the program and recompiled it, while debugging using breakpoints I see that it is reading all the rest data that it wasn't reading yesterday, it's processing the function it ignored yesterday, but now instead it is giving me some error just in the end, something about access violation at xxxxx.
I'll try to resolve this somehow, if anyone has suggestions please post.