I'm reading a file as below:
#include <fstream>
std::ifstream infile("example.txt");
for (std::string line; std::getline(infile, line);)
{
std::cout << line << std::endl;
}
Now, I want to read the line and delete the line once I have read it. In the end, the example.txt
should be empty. I'm wondering if there is any way I can do that in C++.
Thanks!