如何使用vc ++删除现有文件?

时间:2011-07-22 10:13:37

标签: visual-studio-2008 visual-c++

我使用vc ++ 6.0

创建一个名为newEntry.txt的文件
memset(szLogPath,'\0',sizeof(szLogPath));
strcpy(szLogPath, g_szInstallDir);
strcat(szLogPath, "newentry.txt");

我正在写一些内容

file。我需要在运行代码时创建一个新文件,而不是在旧的

中编写

file.I能够创建文件但是如果我尝试使用

删除文件
remove("szLogPath");

它没有删除,内容最后附加。如何删除该文件?

任何人都可以告诉我要删除该文件需要做什么?

1 个答案:

答案 0 :(得分:0)

szLogPath应该用作变量,而不是字符串。

int remove ( const char * filename );

所以它应该是

remove(szLogPath);

不是remove("szLogPath");