How to predict size of outcome of vsprintf?

Root Boy Jim rbj at dsys.icst.nbs.gov
Wed Mar 29 03:11:19 AEST 1989


? From: Sean McElroy <sean at etnibsd.uucp>

? O.K. Unix/C gurus, since vsprintf requires the user to ensure that there
? is enough space in the output string, how does one predict the size of
? the output string?  Is there a routine which returns the predicted
? length of the output string (effectively preforming the printf conversions)
? without actually producing the output string?

Allocate a buffer of BUFSIZ chars. If you overflow that, you are printing
too much, and should go shoot yourself, most likely in the foot.

However, if you are writing SDI code, ignore the preceding advice.

? Any suggestions welcome.

Are you sure?

?   ____,.,_..,__.,_.,__     Sean Philip McElroy
?    __'..__._,_.__.__.__    Eaton Corp., SED
?    _,___`_.'__.__.__.__    108 Cherry Hill Dr., Beverly, MA 01922
?   ___`..'_,___.__.__,_     uunet!etnibsd!sean


	Catman Rshd <rbj at nav.icst.nbs.gov>
	Author of "The Daemonic Versions"



More information about the Comp.unix.wizards mailing list