How to predict size of outcome of vsprintf?

Sean McElroy sean at etnibsd.UUCP
Sat Mar 18 05:42:52 AEST 1989


It turns out that vfprintf returns the number of characters transmitted
to the file.  If you use /dev/null as the file then it effectively
returns the size of the output message string for vsprintf (less the
terminator.) 

This solution has satisfied me for now although it's inefficient (and uses
up a file descriptor).  Perhaps there are others that I'm not aware of which
don't have the same inefficiencies.  I'm still interested in hearing about
them.

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



More information about the Comp.unix.wizards mailing list