Trying to do something like...
But apparently fin.eof() doesn't work...what can I check for?Code:while(!fin.eof()) { // stuff here }
Trying to do something like...
But apparently fin.eof() doesn't work...what can I check for?Code:while(!fin.eof()) { // stuff here }
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
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 }
My best code is written with the delete key.
Thanks, got it to work!
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
suppose you had
char ch;
fin.get(ch);
how does one check for eof of ch?