C++ clear data in text file

std::ifstream File;
std::string filepath = "text.txt";
File.open(filepath.c_str(), std::ifstream::out | std::ifstream::trunc );
if (!File.is_open() || File.fail())
{
File.close();
printf("\nError : failed to erase file content !");
}
File.close();

posted @ 2020-01-21 10:40  一只羊JAS  阅读(165)  评论(0编辑  收藏  举报