Feb 3, 2010 at 3:23am UTC
I am reading some number matrix from a text file . I had two pieces of code
1:
ifstream ifs;
//open file
while(!ifs.eof()){
//getline & other stuff
}
2:
ifstream ifs;
//open file
while(getline(ifs,some_string_variable){
//other stuff
}
The first one always get one duplicate of the last number while the second works great. Can someone explain the difference here?
Feb 3, 2010 at 3:55am UTC
Ummmm perhaps include what that "other stuff" is? Otherwise, it is not very clear why the while loops are not the exact same.
Also there seems to be a missing ) in the second one.
Last edited on Feb 3, 2010 at 3:56am UTC
Feb 3, 2010 at 5:12pm UTC
another reason is maybe because he is using binary mode.. ios::binary