[comp.sys.sun] Mystifying sprintf man page

guy@uunet.uu.net (Guy Harris) (06/27/90)

>The man page for sprintf() on this Sun 3/80 I'm using has the following
>statement:
>
>     The return value of sprintf() is not  normally
>     used, but cast to type void instead.
>
>There's no explanation as to why.

Well, you also asked

>Also, doesn't SV return a pointer to the new string as well?

The answer to that question is "no, it returns the number of characters
inserted into the string".  The fact that different versions of UNIX have
"sprintf()" return different values is the reason why programmers who want
their code to work on multiple flavors of UNIX don't use the return value
of "sprintf()". 

Fortunately, ANSI C specifies that all the "printf()"-family routines
return the number of characters generated, so eventually in all systems
"sprintf()" will return the same value.