Mail Archives: djgpp/1999/08/25/21:52:38
Chih Hui <wenzh AT singmail DOT com> wrote in message
news:37820CEB DOT 3832DCC1 AT singmail DOT com...
> No, I mean to clear the input stream of any characters. For example,
> when I run
> the code below, I enter 'A' at the first prompt. getchar() would
> correctly get
> the letter 'A', but the second getchar() would simply get the newline
> character
> leftover from the first getchar().
>
> In Turbo C, a convenient, though non-standard, way is to fflush(stdin),
> which will
> discard all the pending characters in the standard input. How do I
> achieve this in
> DJGPP?
>
Why not use getch() or getche() instead of getchar()? Since getch() and
getche() are unbuffered you don't need to worry about clearing any pending
input because there won't be any. These functions are also available in
Turbo C I think.
- Raw text -