About fstream seekg

I open file like this:
1
2
3
std::fstream in(fn, std::ios::in | std::ios::binary);
	if(!in.is_open())
		return 0;


Then in a loop i need to move cursor forward and break it if it is out of file range:
1
2
3
4
5
in.seekg(iff.size, std::ios::cur);
			if(!in.good())
			{
				break;
			}


What function to use to check if seekg fails?
Since with good() i got bad_alloc() exception.

VS 2010

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.