在 C 编程中,我学习了file io
并运行了以下示例代码:
#include <stdio.h>
main()
{
FILE *fp;
fp = fopen("E:\\tmp\bae.txt", "w+");
fprintf(fp, "This is testing for fprintf...\n");
fputs("This is testing for fputs...\n", fp);
fclose(fp);
return 0;
}
这里代码工作正常,fputs()
返回-1,这意味着代码工作正常。我在E:驱动器上创建了一个目录tmp
,但此代码不会创建文件bae.txt
..'
谁能告诉我为什么会这样?
答案 0 :(得分:5)
而不是
html content is hello martin
attribute value is hello ricky
使用
fp = fopen("E:\\tmp\bae.txt", "w+");
因为 fp = fopen("E:\\tmp\\bae.txt", "w+");
在字符串中具有特定含义。