请教一个 fopen_s 的问题!
代码是这样的:
程序代码:#include <stdio.h>
int main(void)
{
int i = 100;
char * filename = "E:\\myfile.txt";
errno_t err;
FILE * pfile = NULL;
err = fopen_s(&pfile, "filename", "a");
if (err != 0)
printf("The file %s was not opened.\n", filename);
else
printf("The file %s was opened.\n", filename);
fclose(pfile);
//remove(filename);
return 0;
}
1.运行后显示这个文件已经打开了,但是在E盘并没有创建myfile.txt这个文件。
2.在E盘手动创建myfile.txt这个文件,输入一些内容。fopen_s的第三个参数——模式,改成"w",运行后发现文件中的内容也没有被销毁。
这是为什么呢?是我的文件路径有问题吗?









