我是 C 语言新手,我正在尝试掌握文件处理的窍门。我尝试写入此文件,但它不起作用,我不确定为什么它不起作用,有人可以帮助我吗?
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *f;
f = fopen("out.txt","w+");
if (f == NULL) {
printf("ERROR");
exit(-1);
}
char test[] = "HELLO";
fprintf (f, "%s", test);
fclose(f);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我检查文件是否已打开时,我不断收到“错误”消息:/