PDA

View Full Version : fread's file.open will NOT WORK no matter what



06-23-2000, 11:28 AM
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?

frogger
06-23-2000, 11:54 AM
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).]

Bob
06-23-2000, 01:16 PM
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 \\.