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...
}
 
Back
Top