I am making a function that simply writes "hello" to a file. I put it in another file and included its header in the program. But gcc gives an error, namely: error: unknown type name 'FILE. The code is below
app.c:
#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"); }
when compiling with gcc, the following happens:
harsh@harsh-Inspiron-3558 :~/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){ ^
Sorry for any errors. I start.
source share