www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/25/21:52:38

From: "Marp" <Marp AT 0 DOT 0 DOT 0 DOT 0>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Flushing input stream?
Date: Tue, 6 Jul 1999 13:07:48 -0400
Organization: Netcom
Lines: 24
Message-ID: <7ltd5c$ab@dfw-ixnews19.ix.netcom.com>
References: <37819F79 DOT 72629349 AT singmail DOT com> <3781B0AF DOT 8905D645 AT earthlink DOT net> <37820CEB DOT 3832DCC1 AT singmail DOT com>
NNTP-Posting-Host: prn-nj1-13.ix.netcom.com
X-NETCOM-Date: Tue Jul 06 12:07:56 PM CDT 1999
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


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