파일에 "hello"를 쓰는 기능을 만들고 있습니다. 나는 그것을 다른 파일에 넣고 프로그램의 헤더를 포함 시켰습니다. 그러나 gcc는 오류를 제공합니다 : 오류 : 알 수없는 유형 이름 'FILE'.오류 : 알 수없는 형식 이름 'FILE'
가#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;
}
write_hello.h :
가void write_hello(FILE*);
write_hello.c :
void write_hello(FILE* fp){
fprintf(fp,"hello");
printf("Done\n");
}
다음과 gcc에서 컴파일 발생 코드는
가 APP.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''도. 'FILE'은'stdio.h '에 정의되어 있습니다. –