Testing if file open() command successful

C

Colum

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
 
M

Moonlit

Hi,

Colum said:
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.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top