sprintf(3s) query

Knudsen knudsen at ihlpl.ATT.COM
Wed Dec 14 02:39:54 AEST 1988


Funny you should mention Sun and sprintf().  I have just
learned the hard way that while most (???) C systems
have sprintf return the number of characters written,
the Sun version returns the buffer address!
Let's hear it for STANDARD I/O Libraries!

Both return values are useful, but I'd rather have the integer
number of characters, since otherwise a strlen() call is needed
to get this.

Funny, most programmers don't even know what the printf family's
return values are supposed to be (thus permitting Sun to
define them as they please?).  You can always declare
	(void) printf(), sprintf(), fprintf();
to shut up lint, but sometimes I want those return values.

Have you tested printf() and fprintf() on Sun to see what THEY return?
On AT&T 3B2 they all return number of characters.
-- 
Mike Knudsen  Bell Labs(AT&T)   att!ihlpl!knudsen
"Lawyers are like nuclear bombs and PClones.  Nobody likes them,
but the other guy's got one, so I better get one too."



More information about the Comp.lang.c mailing list