Mail Archives: djgpp/1999/07/07/09:01:18
On Tue, 6 Jul 1999, Chih Hui wrote:
> Hi, how do I flush the standard input stream in DJGPP? In other
> compilers, I could use the non-standard way by using fflush(stdin).
It depends on what level do you want to empty the input. Borland's
fflush(stdin) only empties the characters buffered in the stdin FILE
object. This effect can be achieved by calling fseek, like this:
fseek (stdin, -66000, SEEK_CUR);
(The magic number 66000 is meant to be larger than any possible size
of the so-called transfer buffer used by a DJGPP program to pass data
to and from real-mode services.)
Note that the above doesn't empty the keyboard buffer; if you need
that, use BIOS functions like `kbdhit'.
- Raw text -