Hi,
I've been working on this C assignement for a CS course.... the
assignement is going pretty well and all my code works well on both
Windows and Linux.
The only thing that doesn't work is a stupid function that only has to
wait for a keypress from the user (it's a CLI program).
Here's what I have :
void wait(void)
{
fflush(stdin);
printf("\nPress Enter to continue...");
getchar();
}
The fflush() is there to get rid of some leftover \n in the input queue
(from a previous scanf() for instance). It works under Windows (the
fflush(stdin) works), but it doesn't under Linux. And I already know
that "fflush(stdin)" is wrong (fflush() is supposed to be for output
buffers, not input... or something like that).
So what do you gurus think ? What would be a right/portable way to wait
for a keypress (any key if possible, not just ENTER) and be sure that no
"leftover" \n will jinks it ?
Thanks for your help !
Alex....