Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!ulysses!kpv From: kpv@ulysses.att.com (Phong Vo[drew]) Newsgroups: comp.lang.c Subject: Re: Possible scanf bug? Message-ID: <14285@ulysses.att.com> Date: 7 Feb 91 21:19:09 GMT References: <16134@sdcc6.ucsd.edu> <146@thor.UUCP> <3343@unisoft.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 16 In article <3343@unisoft.UUCP>, greywolf@unisoft.UUCP (The Grey Wolf) writes: : 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 ] : : 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] What is uncleared is the meaning of "matched". Since the "" string is legitimate, it is arguable that string matching patterns should always satisfy except for eof. Therefore, it can be argued that sscanf("1,,3","%[^,],%[^,],%[^,]",s1,s2,s3) should return three matches where s2 will contain the null string. Note that the situation is not the same for numerical matching where there is no "legitimate" undefined numbers.