could someone give me an example of using one of the flags with file I/O for example. If your file is written return good() or something like that, I have the keywords, but I don't know the implementation. Thanks in advance.
Printable View
could someone give me an example of using one of the flags with file I/O for example. If your file is written return good() or something like that, I have the keywords, but I don't know the implementation. Thanks in advance.
fstream f1;
if(f1.good() && !f1.bad() && !f1.fail() )
cout<<"FILE IS OK";
else
cout<<"SOMETHING'S WRONG";
i guess that's the way to use it... (thats the way i use it)
you can also use just f1.good() or !f1.bad() or !f1.fail() in the is cndtn
Thanks I tried it and it worked.