Date: Thu, 30 May 1996 13:11:05 +0200 (IST) From: Eli Zaretskii To: Dominique Micollet Cc: djgpp AT delorie DOT com Subject: Re: fflush(stdin) : does it works ? In-Reply-To: <4ohpaj$i0j@tempo.univ-lyon1.fr> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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).