delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/10/07:45:15

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: fflush (in djgpp)
Date: 10 Apr 2001 11:35:24 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 22
Message-ID: <9aur5s$6mb$1@nets3.rz.RWTH-Aachen.DE>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1010409094239 DOT 27683L-100000 AT is>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 986902524 6859 137.226.32.75 (10 Apr 2001 11:35:24 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 10 Apr 2001 11:35:24 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
> On Mon, 9 Apr 2001, Jack Klein wrote:

>> There is nothing that scanf() can do that fgets() followed by other
>> functions, including sscanf(), can't do as well or better.

> This argument goes both ways: scanf and fgets+sscanf are functionally
> equivalent.  A C programmer should master both, IMHO.

Actually, I'd claim that both the above are subtly wrong. 

scanf() (with a cleverly designed format string) can skip over
"infinitely" large input without actually copying them into
program-internal storage --- you can't do that with fgets()+sscanf().

OTOH scanf() is not functionally equivalent to fgets()+sscanf() ---
the problem is ambiguous input. fgets() lets you go back and re-try.
With scanf(), you have to split up the input into small fragments (or
abuse scanf() to behave like fgets(), and sscanf() later).
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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