C Programming: Keep reading a text file even if there is a blank line

Hey guys, with the assignment that I'm currently working on I have words that I need to place in a char *buffer variable. I'm using the fgets() function to achieve this goal.

Here is a sample data of the file:
silver
simple
sister
size
skin

skirt

Note that the new line between the words skin and skirt are intentional. The problem that I'm encountering is how to keep reading that next word since its not really the end of file yet. Thanks for the help guys!

Did you search on Google ? Found plenty of code snippets and solutions by simply searching for "C read until end of file". What did you try searching for ?

For C Programming, I suggest just going to comp.lang.c's wonderful FAQ that should answer any questions you may have. Faster than doing forum posts with close to 0 details.

It really depends on how you're doing input. If using fgets(), check the return value instead of the contents of the buffer. If using getchar() try to see if there's a constant that might indicated the End-Of-File marker (big hint in bold there). Check to see if there's any functions that can indicate a File's End-Of-File () marker was reached (again, big hint in bold).

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.