Answer the question
In order to leave comments, you need to log in
How to clear a file using file I/O streams without closing it?
I want to open a file, write a line to it, then, without closing the file, start writing again, so that the old information is deleted:
std::ofstream file;
file.open("file.txt", std::ios_base::in | std::ios_base::out);
file << "AA";
file.seekp(std::ios::beg);
file << "1";
file.close();
1A
and should be1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question