C语言中清除文件中保存的内容要怎么写?
有一种文件打开方式叫trunc,解释是If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one。 意思是如果打开文件输出,文件本来存在,那么先删除原来内容,在用新的输出代替。你可以
ofstream file;
file。open("文件名字", ios::trunc); //这样打开文件,就把原来的东西删了。 你在输入个空格什么的就行了。全部
有一种文件打开方式叫trunc,解释是If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one。
意思是如果打开文件输出,文件本来存在,那么先删除原来内容,在用新的输出代替。你可以
ofstream file;
file。open("文件名字", ios::trunc); //这样打开文件,就把原来的东西删了。
你在输入个空格什么的就行了。收起