Is there a way to flush the input buffer like this:
But without having to hit enter?Code:while ((ch = getchar()) != '\n' && ch != EOF);
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?