Definition | #include <stdarg.h> int vnsprintf(char *s, size_t n, const char *format, va_list arg);
|
Parameters
char *s
Pointer to the result string. vsprintf
terminates the string with the null byte (\0). The maximum length of the output is therefore n-1.
size_t n
Length of the area reserved for the result string. n may not be greater than INT_MAX
. When n = 0, no output takes place.
const char *format
Format string as described under printf with ANSI functionality (cf. printf
).
The only difference is the way in which the control characters for white space (\n, \t, etc.) are handled: vsprintf
enters the value of the control character into the result string. It is only during output to text files that the control characters are converted to their appropriate effect depending on the type of text file (see section “White space” (Basic terms)).
va_list arg
Pointer to the variable argument list initialized with va_start
.
Returnwert | n > INT_MAX or output error. It was possible to edit the output completely. The return value specifies the It was not possible to edit the output completely. The return value specifies | |
= 0 .. n-1 > n |
Notes vsnprintf
always starts with the first argument in the variable argument list. It is possible
to start output from any particular argument by issuing the appropriate number of va_arg
calls before calling the vsprintf
function. Each va_arg
call advances the position in the argument list by one argument.
vsnprintf
does not call the va_end
macro. Since vsnprintf
uses the va_arg
macro, the value of arg is undefined on return.
The behavior is undefined if memory areas overlap.
See also
vfprintf, vprintf , vsprintf