ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/30/06:13:52

Date: Thu, 30 May 1996 13:11:05 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Dominique Micollet <dmicolet AT u-bourgogne DOT fr>
Cc: djgpp AT delorie DOT com
Subject: Re: fflush(stdin) : does it works ?
In-Reply-To: <4ohpaj$i0j@tempo.univ-lyon1.fr>
Message-Id: <Pine.SUN.3.91.960530130506.15158A-100000@is>
Mime-Version: 1.0

On 29 May 1996, Dominique Micollet wrote:

> The %[^\n] allows to catch any character excepted the new line and then to
> get strings with blanks, tabs and so on inside them.
> The fflush(stdin) is there to trash the new line, else the next scanf of a
> string does not works.
> This works fine with many compilers (RS6000, SUN, DEC, PC)

ANSI C Standard says (para 7.9.5.2) that `fflush' is only defined for
output streams; otherwise what `fflush' does is undefined.  You shouldn't
use `fflush' at all for an input stream.  To skip the newline, use `fgets'
(or just `getc' if you know there is only a single newline). 

- Raw text -


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