Curious Behaviour of "sscanf"

Joel Anderson anderson at c10sd3.StPaul.NCR.COM
Fri Jun 17 23:50:17 AEST 1988


People using the C compiler on NCR Towers here in St.Paul have noted
a curious (well, at least unexpected) behaviour in the sscanf function.

On a call to sscanf as follows:
               .
               .
               .
               if (sscanf(argv[3],"X=(%d,%d)",&y,&z) == 2) 
               .
               .
               .

and an input string where argv[3] is as follows:

               "X=(1,4"

(not including the double quotes), why does sscanf in this case evaluate to
true?  Sscanf matches the number of arguments but does not continue parsing
the control string (i.e. true even though the closing paren is missing)?

Perhaps this is correct - is it?

Thanks&shalom

Joel.



More information about the Comp.lang.c mailing list