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();

猜你喜欢

转载自www.cnblogs.com/jieliujas/p/12220895.html
今日推荐