From: Hans-Bernhard Broeker 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: 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 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.