Check for empty file.

I need to check if my text file is empty. If so, I exit the program. But, I need to do this without reading anything into a buffer as to not lose any text if it is not empty.

My code is basically:
1
2
3
4
while(get_line(input) >=0){
    blah blah blah
}
prinf(stuff)


So I can't just say:
1
2
if(input ==EOF)
   exit(1);
because after I read through the file I need to print(not during). And I have to exit or my print section will seg-fault.
Last edited on
Check the size with stat()
Thanks a bunch.
Topic archived. No new replies allowed.