www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/08/23:30:34

From: Jack Klein <jackklein AT spamcop DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: fflush (in djgpp)
Message-ID: <dla2dto2m73ssffe78j3bn5pepr6lof116@4ax.com>
References: <9aqfuu$fnb$1 AT uranium DOT btinternet DOT com> <82j1dtc5m6lg195fo29ddc7r19vrp4v0k7 AT 4ax DOT com> <4331-Sun08Apr2001231754+0300-eliz AT is DOT elta DOT co DOT il>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Lines: 34
Date: Mon, 09 Apr 2001 03:24:03 GMT
NNTP-Posting-Host: 12.75.153.188
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc06-news.ops.worldnet.att.net 986786643 12.75.153.188 (Mon, 09 Apr 2001 03:24:03 GMT)
NNTP-Posting-Date: Mon, 09 Apr 2001 03:24:03 GMT
Organization: AT&T Worldnet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sun, 08 Apr 2001 23:17:55 +0200, "Eli Zaretskii"
<eliz AT is DOT elta DOT co DOT il> wrote in comp.os.msdos.djgpp:

> > From: Jack Klein <jackklein AT spamcop DOT net>
> > Newsgroups: comp.os.msdos.djgpp
> > Date: Sun, 08 Apr 2001 20:49:13 GMT
> > 
> > The real work around is to never, never use scanf() for interactive
> > user input.  The function is poorly designed in the first place, and
> > it can be tricky to use
> 
> scanf isn't poorly designed, it's just very powerful and takes time to
> master.  Newbies are well advised to avoid using it for interactive
> input.
> 
> But if you do master scanf, you can do anything with it; so there's no
> need to scare users from trying to learn scanf better.
> 
> > If you think I am exaggerating, run the program that you have and
> > enter "xyz" at the first prompt for age and see what happens.  Even on
> > some systems that define a non-standard extension to fflush() that
> > does what you think you want it to do, it does not fix a problem like
> > this.
> 
> With a proper format string, this can be handled with scanf as well.

Yes, and one can spend years designing scanf() conversion specifiers.
There is nothing that scanf() can do that fgets() followed by other
functions, including sscanf(), can't do as well or better.  And you
don't hang the stream.

-- 
Jack Klein
Home: http://JK-Technology.Com

- Raw text -


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