Is there a way to flush the input buffer like this:
Code:
while ((ch = getchar()) != '\n' && ch != EOF);
But without having to hit enter?
If you do this after calling fgets() you have to hit enter twice. I presented my problem to my instructor yesterday and no surprise he told me to use fflush(stdin). I didn't want to correct him, I just did it so I can pass (lucky for me it worked anyway). But is there another way to do it?