如何删除已在VC ++中创建的文本文件,以便为每次执行创建一个新文件? [英] How to delete a text file tha has been created in VC++ so that a new file is created for each execution?

查看:121
本文介绍了如何删除已在VC ++中创建的文本文件,以便为每次执行创建一个新文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以给我示例代码来删除使用fopen函数创建的文本文件,以便为每次执行创建一个新文件...在VC ++中是可能的...还是请告诉我如何清除文件的内容,以便每次执行时文件都为空...请帮助我...
谢谢...:困惑:

can anyone please give me th sample code for deleting a text file that is created using fopen function so that for each execution a new file is created... Is it posible in VC++... Or please tell me how to clear the contents of the file so that for every execution the file is empty... please help me out...
Thank you...:confused:

推荐答案

您是否已阅读msdn [ ^ ]?它清楚地表明,当使用mode ="w"打开文件时,"...如果给定文件存在,则其内容将被破坏." 所以我想您要做的就是打开再次归档.

-Saurabh
Did you read the documentation for fopen in msdn[^]? It clearly says that when a file is open with mode = "w" then "... If the given file exists, its contents are destroyed." So I guess all you have to do is open the file again.

-Saurabh


您的意思是每次打开文件都想拥有一个空文件吗?如果是,则只需以写入模式打开文件.请参阅文档 [
You mean you want to have an empty file each time you open the file ? If yes, then just open the file in write mode. See the documentation[^] for more info.


这篇关于如何删除已在VC ++中创建的文本文件,以便为每次执行创建一个新文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆