我不明白为什么这不起作用。为什么fopen无法正常工作?
#include <stdio.h>
int main(void) {
FILE *in, *out;
// char *FULLPATH = "C:\\Users\\Jay\\c\\workspace\\I-OFiles\\in.txt\\ ";
// char *mode = "r";
// in = fopen(FULLPATH, mode);
//
// if (in == NULL) {
// perror("Can't open in file for some reason\n");
// exit (1);
// }
out = fopen("C:\\Users\\Jay\\c\\workspace\\I-OFiles\\out.txt", "w");
if (out == NULL) {
perror("Can't open output file for some reason \n");
exit(1);
}
fprintf(out, "foo U");
fclose(in);
fclose(out);
return 0;
}
,如果我从注释行中删除//错误编译器使是
:无效的参数
我不明白为什么(我读了所有其他线程相关,而且什么也没有)。 它实际上编写了out.txt文件,所以它看起来不像路径拼写错误的问题。
'in.txt \\' - >'in.txt' –
你确实有一个叫做'in.txt'目录? – melpomene
感谢@SouravGhosh,我不知道还有什么可以尝试的 – newbie