Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!uunet!unisoft!greywolf From: greywolf@unisoft.UUCP (The Grey Wolf) Newsgroups: comp.lang.c Subject: Re: Possible scanf bug? Message-ID: <3343@unisoft.UUCP> Date: 5 Feb 91 21:32:57 GMT References: <16134@sdcc6.ucsd.edu> <146@thor.UUCP> Reply-To: greywolf@unisoft.UUCP (The Grey Wolf) Organization: Foo Bar and Grill Lines: 37 In article rjohnson@shell.com (Roy Johnson) writes: >In article <146@thor.UUCP> scjones@thor.UUCP (Larry Jones) writes: [ scanf not reading what the user wants, said to return zero ] >Except that it would return 1, for number of variables assigned, not >number of formats read. From BSD 4.3 UNIX, scanf(3S) manual page: "The _s_c_a_n_f functions return the number of successfully matched and assigned input items[*]. This can be used to decide how many ^^^^^^^^^^^^^^^^^^^^ [implies both] input items were found. The constant EOF is returned upon end of input; note that this is different from 0, which means that no conversion was done; if conversion was intended, it was frustrated by an inappropriate character in the input." The Pyramid OSx (BSD) man page reads likewise. [*] The SunOS 3.5 and 4.0.3 manuals and the Pyramid OSx (AT&T) man page read similarly, but with the stipulation inserted here: "...this number can be zero in the event of an early conflict between an input character and the control string. > >-- >======= !{sun,psuvax1,bcm,rice,decwrl,cs.utexas.edu}!shell!rjohnson ======= >"If he exploded, all of Manhattan would be talking in high, squeaky voices >for months!" "Cool." -- When I Was Short >Roy Johnson, Shell Development Company Of course, how it actually works in *practice* may vary from system to system (depending upon how braindead your implementation of the stdio functions is). -- thought: I ain't so damb dumn! | Your brand new kernel just dump core on you war: Invalid argument | And fsck can't find root inode 2 | Don't worry -- be happy... ...!{ucbvax,acad,uunet,amdahl,pyramid}!unisoft!greywolf