delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/07/21:35:39

From: "Christopher Nelson" <paradox AT gye DOT satnet DOT net>
To: <djgpp AT delorie DOT com>
Subject: Re: Flushing input stream?
Date: Wed, 7 Jul 1999 14:12:41 -0600
Message-ID: <01bec8b5$11218dc0$LocalHost@thendren>
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Reply-To: djgpp AT delorie 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? 


    while(getc()!=EOF);


    -={C}=-



- Raw text -


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