VSPRINTF - print variable argument list into string.

(ANSI Standard)

Usage:

#include <stdarg.h>
#include <stdio.h>
nout = vsprintf(str,format,varlist);

Where:

char *str;
points to the string where the output will be written.
const char *format;
is a standard "printf" format string.
va_list varlist;
is a variable argument list consisting of the values to be printed.
int nout;
is the number of characters output (not counting the '\0' on the end of the string). If the print operation failed for some reason, a negative number is returned.

Description:

"vsprintf" is the same as "sprintf" except that it prints out a number of values from a variable argument list. The "varlist" variable must have been initialized with the "va_start" macro. If there have already been calls to "va_arg" to obtain arguments from the variable list, "vsprintf" will start at the first argument that has not yet been obtained through "va_arg". "vsprintf" effectively uses "va_arg" to obtain arguments from the variable list; therefore a call to "va_arg" after "vsprintf" will obtain the argument AFTER the last argument printed.

After a call to "vsprintf", the "varlist" variable should be assumed to be in an undefined state. If you want to use "varlist" again, you must call "va_end" to clean up, then "va_start" to reinitialize it.

See Also:

expl c lib printf

expl c lib sprintf

expl c include stdarg

Copyright © 1996, Thinkage Ltd.