Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22052

error: unknown type name ‘FILE’

$
0
0

I am making a function which is just writes "hello" to a file. I have put it in a different file and included its header in the program.But gcc is giving an error namely: error: unknown type name ‘FILE’. The code is given 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 by gcc the following occurs:

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 mistakes.I am a beginner.


Viewing all articles
Browse latest Browse all 22052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>