Explain this sscanf behavior.

Bradford R. Daniels daniels at tle.enet.dec.com
Sat Jul 7 08:17:06 AEST 1990


> compiler A:

> 	x=1   a=123  b=3
> 	x=1   a=123  b=3

This is the correct result.

> compiler B:
> 	x=1   a=123  b=3
> 	x=1   a=123  b=4  <-- yes 4.

This is clearly wrong, since there aren't even 4 characters in the string...

> compiler C:
> 	x=1  a=123  b=3
> 	x=1  a=123  b= -99

This is also wrong, since %n does not consume any input, and so the
lack of input should not cause it to fail.

> I'm confused????!!!!! Compiler C is "100% ANSI compatible".????

ANSI compatible does not mean bug free.  This behavior is a bug, and
I think I see how it's happening...  In fact, I think I'll go make sure
my RTL doesn't have the same problem...

- Brad

-----------------------------------------------------------------
Brad Daniels			|  Digital Equipment Corp. almost
DEC Software Devo		|  definitely wouldn't approve of
"VAX C RTL Whipping Boy"	|  anything I say here...



More information about the Comp.std.c mailing list