Jun 11, 2010 at 6:26am Jun 11, 2010 at 6:26am UTC
hello
let's reOpen it,and close it!
ofstream ofile( "train.txt", ios::out );
if (!ofile.is_open())
{
std::cout << "OpenFile train.txt Errors!" << std::endl;
}
ofile.close();
If the file already exists, the old version is deleted.
my English is poor, i hope you can understand.
Jun 11, 2010 at 10:29am Jun 11, 2010 at 10:29am UTC
Hi ,
Why cant you delete the file and create the new file with the same name .
or you can create open the file in the write mode and then close it which will delete all its content .
Jun 11, 2010 at 11:08am Jun 11, 2010 at 11:08am UTC
If you want to ensure deletion of the contents, open the file with the ios::trunc
flag... which will truncate the file;)...