delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/04/15:53:09

From: buers AT gmx DOT de (Dieter Buerssner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: fflush ???
Date: 4 Apr 2000 19:01:48 GMT
Lines: 14
Message-ID: <8cde6r$68gj3$1@fu-berlin.de>
References: <8cd85b$jag$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
NNTP-Posting-Host: pec-44-36.tnt3.s2.uunet.de (149.225.44.36)
Mime-Version: 1.0
X-Trace: fu-berlin.de 954874908 6570595 149.225.44.36 (16 [17104])
X-Posting-Agent: Hamster/1.3.13.0
User-Agent: Xnews/03.02.04
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

florent AT oih DOT rwth-aachen DOT de (Florent) wrote:

[...]
>yes. I start to believe in it when I tried to flush my buffer when I
>wanted to use scanf function. If I put something wrong or something too
>big, the buffer still have some datas inside, even with a fflush(stdin),
>then of course the programs goes down.

fflush will only work on output streams in standard C. So using fflush
on an input stream is wrong (even when it works with some C 
implementations). I would suggest to use fgets and sscanf (or even
strtod, strtol etc.) instead of scanf, to solve your problem.

-- Dieter

- Raw text -


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