By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,233 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,233 IT Pros & Developers. It's quick & easy.

Testing if file open() command successful

P: n/a
Hi,
Does anyone know how to check if the ofstream open() command was successful.
My program tries to open a file on a floppy disk and I want to ensure that
the disk is present in the drive by checking if the open() command succeeded
Thanks
Colum
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

"Colum" <co********@hotmail.com> wrote in message
news:vd****************@news.indigo.ie...
Hi,
Does anyone know how to check if the ofstream open() command was successful. My program tries to open a file on a floppy disk and I want to ensure that
the disk is present in the drive by checking if the open() command succeeded Thanks
Colum


ofstream File( "a:\\file.txt" );

if( !File.is_open() )
{
cerr << " File is not open" << endl;
}

Regards, Ron AF Greve.
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.