bug in sscanf (scanf)?
John Woods
john at frog.UUCP
Fri Nov 18 15:04:00 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]", ×, s1, s2, s3, s4);
The problem is here.......................^^
That puts a NUL byte into the format string, which terminates it; as far as
C semantics are concerned, scanf should assume that nothing follows it.
XENIX evidently blithely went on, but System V definitely stops (and ignores
the format specification) if it sees a premature NUL byte.
--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, john at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu
Science does not remove the TERROR of the Gods!
More information about the Comp.bugs.sys5
mailing list