J
John Smith
I would like to write over a file if it exists (or create one if
it doesn't exist). The following codes do nothing if the file
already exists. How do I get it to overwrite an existing file?
Also, if the existing file is longer than what's going to be
written, how do I erase the excess portion of the existing file?
fsF.open ("test.txt", ios:ut|ios::trunc);
if (fsF.fail())
{
cout << "File test.txt cannot be opened.";
fsF.clear();
}
fsF << something
fsF.close();
it doesn't exist). The following codes do nothing if the file
already exists. How do I get it to overwrite an existing file?
Also, if the existing file is longer than what's going to be
written, how do I erase the excess portion of the existing file?
fsF.open ("test.txt", ios:ut|ios::trunc);
if (fsF.fail())
{
cout << "File test.txt cannot be opened.";
fsF.clear();
}
fsF << something
fsF.close();