#include <stdio.h>
main(void) {
file *file = fopen("words.txt","r")
if(file != null) {
char line[128];
while(fgets( line, sizeof line, file) != null)
{
fputs ( line, stdout );
}
fclose ( file );
}
}
This is my code. im trying to read a file, and output the content. but this gives me error codes
main.c: In function 'main':
main.c:4: error: 'file' undeclared (first use in this function)
main.c:4: error: (Each undeclared identifier is reported only once
main.c:4: error: for each function it appears in.)
main.c:5: error: parse error before "if"
main.c:7: error: 'line' undeclared (first use in this function)
main.c:7: error: 'null' undeclared (first use in this function)
main.c: At top level:
main.c:13: error: parse error before '}' token
main.c:13:2 warning: no newline at end of file
how do i fixs this errors.