The Problem
I usually use fgets()
or getchar()
, but now I need to use getch()
, because I don't want to press enter to send a char to the input buffer.
What I tried
When I used fgets()
and getchar()
I also used:
int c;
while ((r = getchar()) != '\n' && r != EOF){}
But now if I use it before getch()
it requires me to press enter, which I don't want.
Is there any portable solution to empty the input buffer?