ugliness in scanf(3)

Matt Crawford matt at oddjob.UUCP
Sun May 12 10:18:08 AEST 1985


In article <190 at mplvax.UUCP> cdl at mplvax.UUCP (Carl Lowenstein) writes:
>In article <10496 at brl-tgr.ARPA> gwyn at Brl.ARPA (VLD/VMB) writes:
>>If it ate the "failing" character, you could never see what it
>>was.  I think the routine was designed on the assumption that
>>the programmer would not be so stupid as to keep trying to
>>scan a chunk of input over & over with the same failing format.
>
>*mild flame*
>
>This programmer is so stupid as to expect to find the behavior
>of scanf documented in the manual.
>
>*unflame*
>	carl lowenstein		marine physical lab	u.c. san diego

THIS programmer is not too arrogant to open the manual before telling
someone what's not in it:

SCANF(3S)	    UNIX Programmer's Manual		SCANF(3S)

     For example, .....

	  int i; float x; char name[50];
	  scanf("%2d%f%*d%[1234567890]", &i, &x, name);

     with input

	  56789	0123 56a72

     will assign 56 to i, 789.0	to x, skip `0123', and place the
     string `56\0' in name.  The next call to getchar will return
     `a'.                    ------------------------------------
     ----


If you make a mistake you can (a) admit it, (b) shut up, or (c)
prolong the argument and provide more entertainment.  I will choose
course (a) and admit that I am making a mistake by posting anything
at all on this subject.
_____________________________________________________
Matt		University	crawford at anl-mcs.arpa
Crawford	of Chicago	ihnp4!oddjob!matt



More information about the Comp.lang.c mailing list