Trying to do something like...
But apparently fin.eof() doesn't work...what can I check for?Code:while(!fin.eof())
{
// stuff here
}
Printable View
Trying to do something like...
But apparently fin.eof() doesn't work...what can I check for?Code:while(!fin.eof())
{
// stuff here
}
Using eof() as the loop condition is a Bad Thing, the eofbit is only set after you've tried to read and failed. The end result is usually that you read one more than you want. Try placing your input in the condition of the loop, for example:
-PreludeCode:while ( cin>> var ) {
// All is well, work with var
}
Thanks, got it to work!
suppose you had
char ch;
fin.get(ch);
how does one check for eof of ch?