Possible scanf bug?

Phong Vo[drew] kpv at ulysses.att.com
Fri Feb 8 08:19:09 AEST 1991


In article <3343 at unisoft.UUCP>, greywolf at unisoft.UUCP (The Grey Wolf) writes:
: In article <RJOHNSON.91Jan31110927 at olorin.shell.com> rjohnson at shell.com (Roy Johnson) writes:
: >In article <146 at thor.UUCP> scjones at 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.



More information about the Comp.lang.c mailing list