Originally Posted by
Hermitsky
Code:
fstream openf;
string filename;
......... .........
filename="c:\ooo\111\222\defa.ooo";
..........
openf.open(filename.c_str(),fstream::in|fstream::out);
I think you meant
Code:
filename="c:\\ooo\\111\\222\\defa.ooo";
or
filename="c:/ooo/111/222/defa.ooo";
A single backspace in a C\C++ string represents an escape sequence, there fore will not get the expected result even if your compiler lets it compile.
You could also do this
Code:
bool WriteToFile ( const char *file_name )
{
ostream the_file ( file_name );
// Check if it opened/existed
if ( !the_file.is_open () ) {
// if it didnt
return false;
}
// write to it
the_file.close ();
return true;
}
// to use the function
int main ()
{
if ( !WriteToFile ( "C:/MyFile.txt" ) )
exit ( 1 );
return 0;
}
That should give you a rough idea of things you can do.