When I open a file using ifstream, the open sometimes fails. I use fail() to detect this. But I want to know why it failed and fail() only returns a dumb "yes" or "no". Is there a way to find out?
Printable View
When I open a file using ifstream, the open sometimes fails. I use fail() to detect this. But I want to know why it failed and fail() only returns a dumb "yes" or "no". Is there a way to find out?
you can use the rdstate() member function to read the state of the stream.