创建一个文件,若文件已存在则清空原内容的 c++程序

如题所述

1.用remove函数功能:删除一个文件 用法:intremove(constchar*filename);头文件:在VisualC++6.0中可以用stdio.h返回值:如果删除成功,remove返回0,否则返回EOF(-1)。2.例:#include int main(){ if(remove("1.txt")) printf("Could not delete the file &s \n","1.txt"); else printf("OK \n");return 0;}1.txt在程序目录下
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-10-27
fstream默认就是这样的

~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
相似回答