delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/07/09:01:18

Date: Wed, 7 Jul 1999 15:59:09 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Chih Hui <wenzh AT singmail DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Flushing input stream?
In-Reply-To: <37819F79.72629349@singmail.com>
Message-ID: <Pine.SUN.3.91.990707155822.2851c-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019