delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/07/01:34:11

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Flushing input stream?
Date: Tue, 06 Jul 1999 03:30:55 -0400
References: <37819F79 DOT 72629349 AT singmail DOT com>
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en,fr,de,zh,en-GB,de-CH,fr-CH,zh-CN,cs,el,ja,ru
X-ELN-Date: 6 Jul 1999 07:29:33 GMT
X-ELN-Insert-Date: Tue Jul 6 00:35:03 1999
Organization: Nocturnal Aviation
Lines: 31
Mime-Version: 1.0
NNTP-Posting-Host: dialup-209.246.102.55.newyork2.level3.net
Message-ID: <3781B0AF.8905D645@earthlink.net>
X-Mailer: Mozilla 4.61 [en] (Win95; U)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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).
> Thanks.


Think for a moment.  What do you _mean_ by flushing a buffer.  The action
performed when you flush an output buffer is to complete output which you have
already initiated.  The data which is in the output buffer is written to the
output device.  Now you want to flush an input stream.  This mean you want to
complete pending input.  But that is in fact not what most people mean when they
ask this question.  There is no intuitive "correct" action on "flushing" an
input stream, and there is no defined behavior.  Better you should ask Scott
Nudds.

If you mean "read characters until an end-of-line is read", then you obviously
have the answer stated in your question, and no further answer is required.

> 
> main(){
>   char ch1, ch2;
> 
>   printf("Enter a letter: ");
>   ch1 = getchar();
> 
>   /* flush input here */
> 
>   printf("Enter another letter: ");
>   ch2 = getchar();
> }

- Raw text -


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