Q: how to get the error from fstream <<

Z

zhou

Hi there,

I got an error when writing to a file via ofstream. Is there a way to get detailed reason for the error?
iosstate only has bad and good bits, no good enough to tell me what went wrong.

ofstream fs;
fs.open("aaa");
if ( fs << ....) {
// error
}

Thanks.

Yan
 
J

John Harrison

zhou said:
Hi there,

I got an error when writing to a file via ofstream. Is there a way to get detailed reason for the error?
iosstate only has bad and good bits, no good enough to tell me what went wrong.

ofstream fs;
fs.open("aaa");
if ( fs << ....) {
// error
}

Thanks.

Yan

No, there is no portable way to get a detailed reason for the error.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top