C++将String类型变量的数据存入文件
void writetxt(string filename, string writestring, bool cover)
{
ofstream out_file(filename, cover ? ios::trunc : ios::app);
if (out_file.is_open())
{
out_file << writestring << endl;
out_file.close();
}
else cerr << "无法写入文件" << endl;
}