I am programming on C++. In my code I create a text file, write data to the file and reading from the file using stream, after I finish the sequence I desire I wish to clear all the data inside the txt file. Can someone tell me the command to clear the data in the txt file. Thank you
If you simply open the file for writing with the truncate-option, you'll delete the content.
std::ofstream ofs; ofs.open("test.txt", std::ofstream::out | std::ofstream::trunc); ofs.close();
http://www.cplusplus.com/reference/fstream/ofstream/open/
1.4m articles
1.4m replys
5 comments
57.0k users