Hi, I need to know how to erase the contents a text file after I have written to it, using ofstream.
Thanks
This is a discussion on Writing to a File, then clearing it. within the C++ Programming forums, part of the General Programming Boards category; Hi, I need to know how to erase the contents a text file after I have written to it, using ...
Hi, I need to know how to erase the contents a text file after I have written to it, using ofstream.
Thanks
The default behavior on opening a file with ios:ut is to create it if it doesn't exist, and delete the contents if it does. So you could close the file then reopen it.
You can also use ios::trunc to delete the contents.
The smiley should be ios::out
C++ Is Powerful
I use C++
There fore I am Powerful