我不明白爲什麼這不起作用。爲什麼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