Thread: iostream problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2023
    Posts
    45

    Exclamation file will not open

    Code:
        file.open (pFileName, std::fstream::in);
        if (file.fail())
        {
           cout << "*pFileName:  ";
           for ( int i =0; i <= 7; i++) {
                cout << pFileName[i];  // name is good
           }
           cout << endl;
           std::cerr << "Could not open >" << pFileName << "<\n"; // so is this
           std::cerr << "Error=" << std::strerror(errno) << "\n";  // #include <cerrno>
           AbortTranslation(ac);
           file.clear();
        }
    New updated test code above: results are
    *pFileName: WOLF.PAS
    could not open >WOLF.PAS<
    Error=no such file or directory
    *** Fatal translator error: failed to open source file

    I even copied the WOLF.PAS file into the same directory as the exe
    file was in.

    I've added exec file parameters many times before in Code::Blocks and DevC++ and never had any problems running the exe with filenames.

    This is strange!!!!

  2. #2
    Registered User
    Join Date
    Aug 2023
    Posts
    45
    Quote Originally Posted by maxcy View Post
    Code:
        file.open (pFileName, std::fstream::in);
        if (file.fail())
        {
           cout << "*pFileName:  ";
           for ( int i =0; i <= 7; i++) {
                cout << pFileName[i];  // name is good
           }
           cout << endl;
           std::cerr << "Could not open >" << pFileName << "<\n"; // so is this
           std::cerr << "Error=" << std::strerror(errno) << "\n";  // #include <cerrno>
           AbortTranslation(ac);
           file.clear();
        }
    New updated test code above: results are
    *pFileName: WOLF.PAS
    could not open >WOLF.PAS<
    Error=no such file or directory
    *** Fatal translator error: failed to open source file

    I even copied the WOLF.PAS file into the same directory as the exe
    file was in.

    I've added exec file parameters many times before in Code::Blocks and DevC++ and never had any problems running the exe with filenames.

    This is strange!!!!
    Been on hiatus for a week! In the above loop i <= 7 I believe should be i <= strlen(*pFileName) or else whitespace after the file name will not be found!
    maxcy

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IOSTREAM problem
    By joan in forum C++ Programming
    Replies: 13
    Last Post: 12-01-2006, 02:56 PM
  2. Problem during compile (iostream.h error)
    By JoJo in forum C Programming
    Replies: 4
    Last Post: 04-29-2003, 06:58 PM
  3. iostream problem. Help! :P
    By skyvoyager in forum C++ Programming
    Replies: 4
    Last Post: 08-05-2002, 10:14 PM
  4. iostream.h help???
    By chaoticseedalpha in forum C++ Programming
    Replies: 10
    Last Post: 01-29-2002, 10:12 AM
  5. Iostream
    By Staticman in forum Game Programming
    Replies: 2
    Last Post: 10-16-2001, 03:48 PM

Tags for this Thread