delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/30/22:12:03

From: fredex AT fcshome DOT stoneham DOT ma DOT us
Message-Id: <199605301820.OAA10359@fcshome.stoneham.ma.us>
Subject: Re: fflush(stdin) : does it works ?
To: dmicolet AT u-bourgogne DOT fr (Dominique Micollet)
Date: Thu, 30 May 1996 14:20:22 -0400 (EDT)
Cc: djgpp AT delorie DOT com
In-Reply-To: <4ohpaj$i0j@tempo.univ-lyon1.fr> from "Dominique Micollet" at May 29, 96 03:09:07 pm

Thinking furiously, Dominique Micollet wrote:
> 
> scanf("%[^\n]",One_String);fflush(stdin);
>...
> This works fine with many compilers (RS6000, SUN, DEC, PC)
> 
> It looks like it does not work with DJGPP V2;
> Another try shows me that the stdin is not emptied (spelling ?) at all.
> 
> Is this a known behavior of fflush ?  I am a new user of djgpp (an a old one
> of C) and do not find anything aout that in the FAQ or the info.

This is standard-conforming behavior of fflush(). While I can't, at the
moment, cite a specific reference, the ANSI/ISO standard Does specifically
state that fflush is defined for INPUT streams only. I can, if you need me
to, look it up in the standad and give you the citation. Lemme know.

Therefore, there is no standard-conforming way to flush stdin, and
this behavior on the part of DJGPP is correct (even though not what
you were hoping for!).

Fred

-- 
-------------------------------------------------------------------------------
 .----    Fred Smith    /                        Office: fred AT computrition DOT com 
( /__  ,__.   __   __ /  __   : /                                 508-663-2524 
 /    /  /   /__) /  /  /__) .+'           Home: fredex AT fcshome DOT stoneham DOT ma DOT us 
/    /  (__ (___ (__(_ (___ / :__                                 617-438-5471 
-------------------------------- Jude 1:24,25 ---------------------------------

- Raw text -


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