a simple ofstream open question

  • Thread starter Thread starter Abubakar
  • Start date Start date
A

Abubakar

Hi,

If I write the following code:

ofstream f;
f.open("c:\\hello.txt", ios::binary | ios::out);

how do I check if the file is successfully opened and ready to write ?
Should I do a f.is_open() check ?

Regards,

...ab
 
how do I check if the file is successfully opened and ready to write ?

Try:
if ( f.good() )
{
// Write...
}
 

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

Back
Top