ファイルに「hello」と書いているだけの機能を作っています。私はそれを別のファイルに入れて、そのヘッダをプログラムに入れました。しかしgccはエラーを出しています:エラー:不明な型名 'FILE'。 コードがエラー:不明なタイプ名 'FILE'
app.c下に与えられる:gccでコンパイル時、次が発生
void write_hello(FILE* fp){
fprintf(fp,"hello");
printf("Done\n");
}
:write_hello.h
#include<stdio.h>
#include<stdlib.h>
#include"write_hello.h"
int main(){
FILE* fp;
fp = fopen("new_file.txt","w");
write_hello(fp);
return 0;
}
:
void write_hello(FILE*);
をwrite_hello.cを:
[email protected]:~/c/bank_management/include/test$ sudo gcc app.c
write_hello.c -o app
write_hello.c:3:18: error: unknown type name ‘FILE’
void write_hello(FILE* fp){
^
ご迷惑をおかけして申し訳ありません。私は初心者です。
'の#include'もwrite_hello.c'から。 'FILE'は' stdio.h 'で定義されています。 –