How can I know the reason of the failure of a fstream?

When I open a fstream, it will fail for some reson sometimes, such as the parent directory's absence. Though I can check the failbit to know this situation, can I get the reason of the failure and print some message about the reason?
Last edited on
No.
But there are ways to get this information. In Windows, you can call to GetLastError(), which returns an error code you can put on a switch. You'll have a lot of fun seeing what error codes a certain function can produce, because the MSDN Library certainly won't tell you.
Topic archived. No new replies allowed.