Results 1 to 3 of 3

Thread: fread's file.open will NOT WORK no matter what

  1. #1
    Guest

    fread's file.open will NOT WORK no matter what

    All I want to do is open text file 'tstfile.txt' in the subdirectory 'data'.

    project\data\tstfile.txt

    that simple.

    I want to read the first string of text out of there, which is:

    data\hull.bmp

    but no matter where I tell file.open to get tstfile.txt from, it won't open it and it will give me 'no file found' message.

    code:

    fstream file;
    file.open( "data\tstfile.txt", ios::in/ios::nocreate );


    if ( !file )
    {
    MessageBox( NULL, "No File", "INFO", NULL );
    return 0;
    }

    can somebody compile this, and run it to make sure it works?

  2. #2
    Member Contributor
    Join Date
    May 2000
    Location
    iowa city
    Posts
    63

    Re: fread's file.open will NOT WORK no matter what

    It worked for me if you change the back slash to a forward slash and also change fstream to ifstream (MVC 6.0)

    You of course could use


    FILE file=fopen("data/tstfile.txt", "rb");




    [This message has been edited by frogger (edited 06-23-2000).]

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: fread's file.open will NOT WORK no matter what

    A common error...

    \ means a special character is comming. \n=new line, \t=tab, \a=alarm(a beep)and so on.

    If you want a backslash, you have to type \\.

Similar Threads

  1. PTX file to work with clCreateProgramWithBinary
    By luizdrumond in forum OpenCL
    Replies: 0
    Last Post: 02-06-2012, 03:44 PM
  2. ,exe file does not work on other computer
    By JCheng in forum OpenGL: Windows
    Replies: 8
    Last Post: 04-14-2010, 07:40 AM
  3. Can GLaux file work with Dev-C++??
    By 3rdElement *a* in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-10-2004, 04:42 AM
  4. to work or to not...open gl for games
    By whild_cherry in forum OpenGL: User Software
    Replies: 2
    Last Post: 06-10-2003, 08:58 AM
  5. Y does open gl not work w/ windows xp?
    By Compute Illiterate in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-28-2002, 10:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean