Why is sprintf ifdef-ed out of <stdio.h>?
Guy Harris
auspex!guy at uunet.uu.net
Wed Aug 16 04:20:35 AEST 1989
>The reason is that sprintf() is supposed to return an int value, namely
>the number of characters printed, but it was `too painful' to fix this for
>4.2 and 4.3 BSD, so it was left *wrong* in the BSD VAX systems and made
>correct in SunOS.
More correctly, an attempt was made to make it correct in SunOS 2.0 or so,
but it was, well, too painful, so it was changed back. ("printf" and
"fprintf" were changed in 2.0, though, so that they return the number of
characters printed.)
(Actually, in V7 "sprintf" returned its first argument, although as I
remember this was undocumented; AT&T changed it in S3, but as I remember
some bit of the S3 "sccs" command still depended on the old behavior....
ANSI C specifies the "return the number of characters generated" behavior,
so over time the old behavior will, with any luck, die out.)
More information about the Comp.sys.sun
mailing list