bug in sscanf (scanf)?

Nicholas J. Simicich;? njs at scifi.scifi.UUCP
Fri Nov 18 09:40:06 AEST 1988


In article <331 at zeus.hf.intel.com> martin at zeus.hf.intel.com (Martin Wilde) writes:
>  I have a small fragment of code that does not work on V.3.2 386 UNIX. 
>  The problem appears to be in sscanf (scanf).   The following fragment of
>  code shows the problem.
 .....
>  	(void) sscanf(optarg, "%d %s %s %s %255[^\0]", &times, s1, s2, s3, s4);

The bug is actually in the representation of a string in C, of course
(no flames please).   The format string is being passed to sscanf as:

"%d %s %s %s %255[^"

Since the \0 is an end of string character.  So sscanf can't interpret
what you intended.
--
Nick Simicich --- uunet!bywater!scifi!njs --- njs at ibm.com (Internet)



More information about the Comp.bugs.sys5 mailing list