Clear data inside text file in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Clear data inside text file in c++

Hey guys anybody know how to delete data inside text file, line by line..

25th Mar 2017, 7:49 AM
Madushan Perera
Madushan Perera - avatar
2 Answers
+ 5
use the "truncate" parameter when opening the file related to the link below ofs.open("test.txt", std::ofstream::out | std::ofstream::trunc); http://www.cplusplus.com/reference/fstream/ofstream/open/
25th Mar 2017, 8:42 AM
seamiki
seamiki - avatar
- 1
Thanks Dude.. 👏😊
25th Mar 2017, 9:21 AM
Madushan Perera
Madushan Perera - avatar