在我写这篇文章之前,我查看了许多示例,并且我知道很多语言,并清楚地理解下面列出的代码中的语法和内容,但是,当我编译程序时,例如:
gcc -o /sbin/"name" readfile.c
我收到以下错误:
由于我的代码明确包含#include <stdio.h>
,因此定义此处引用的FILE
---- stdio.h。
// PROGRAM(readfile.c)
#include <stdio.h>
int main(){
FILE *fp;
fp = fopen("dummy.txt","w");
fprintf(fp, "testing...\n");
fclose(fp);
}
// FILE(dummy.txt)*位于同一目录
Hello World
答案 0 :(得分:3)
只是一些小错误
FILE *fp // semi-colon required
fprint(fp, "testing...\n"; // Its fprintf and missing ')'
flcose(fp); // fclose is function
功能为fprintf
而非fprint
,fclose
而非flcose
。
注意 - 您应该检查fopen