The problem that you're experiencing is that getchar() only grabs a single character from the input buffer. This would be fine, except that there's still a newline left in the input buffer that resulted from hitting 'enter' after your input. fgets() is next in your loop, and all it gets is the newline left behind, which is why you get a 0. You need to clear the input buffer after you use getchar() like this:
char c;
while ((c = getchar()) != '\n' && c != EOF);
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339