I'm having the following problem: I'm reading byte-wise a file I've created using a coding algorithm I programmed. When decoding, i can only get to read bytes from 0 to 136 (because EOF is reached), despite the file is 207 bytes long. I'm suspecting EOF could be coded as a certain ASCII character within my file, so I'm could've messed with it when coding the file.
If you're opening it in text mode (which is the default), some of the line break characters are dropped, which might explain why the file is shorter than you expect.
Don't ask me why text mode is the default. I always thought that was retarded.
Sounds pretty interesting. That could be the reason behind some misteries in file sizes ^_^.
I'm having a problem using binary mode. I get errors when reading files using it, despite being able to read the same files using text mode.
1 2 3 4 5
fstream ifs(fichin.c_str()),fstream::binary);
if((!ifs)){ // I only get this error if i use fstream::binary. What should i do?
cout << "* ERROR ! "<<endl;
returnfalse;
}
EDIT : This mistake was plain dumb. I forgot fstream::in .