Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!nrl-cmf!ukma!tut.cis.ohio-state.edu!rutgers!att!ihlpl!knudsen From: knudsen@ihlpl.ATT.COM (Knudsen) Newsgroups: comp.lang.c Subject: Re: sprintf(3s) query Summary: sprintf value screwed up! Message-ID: <8131@ihlpl.ATT.COM> Date: 13 Dec 88 16:39:54 GMT References: <1102@entropy.ms.washington.edu> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 21 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."