About fstream seekg
I open file like this:
std::fstream in(fn, std::ios::in | std::ios::binary);
Then in a loop i need to move cursor forward and break it if it is out of file range:
What function to use to check if seekg fails?
Since with good() i got bad_alloc() exception.
Unhandled exception at 0x7712c41f in Test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0023f838
and it opens "mlock.c" file witch doesn't tell me much where is my mistake.
Thank you for your time
A bad_alloc() exception has nothing to do with the errors flags of your stream.
I think you should simply mesure the size of your file and make sure you don't seek at a position greater than the size.
Topic archived. No new replies allowed.