Testing if file open() command successful

Discussion in 'C++' started by Colum, Dec 18, 2003.

  1. Colum

    Colum Guest

    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
     
    Colum, Dec 18, 2003
    #1
    1. Advertising

  2. Colum

    Moonlit Guest

    Hi,

    "Colum" <> wrote in message
    news:vdoEb.1404$...
    > 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.
     
    Moonlit, Dec 18, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    4
    Views:
    2,177
    Ralf Hildebrandt
    Sep 8, 2003
  2. Mike Lavender

    Successful Download Tracking

    Mike Lavender, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    424
    Bruce Johnson
    Dec 2, 2003
  3. =?Utf-8?B?U2FtLUtpd2k=?=

    detecting successful downloads and browser buffering

    =?Utf-8?B?U2FtLUtpd2k=?=, Dec 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    493
    bruce barker
    Dec 8, 2004
  4. Replies:
    1
    Views:
    567
    Peter Blum
    Jun 14, 2005
  5. paresh

    return value of successful open call

    paresh, Nov 5, 2007, in forum: C Programming
    Replies:
    7
    Views:
    702
    Barry Schwarz
    Nov 6, 2007
Loading...

Share This Page