7.19.6.12 The vsnprintf function

Synopsis

1

#include <stdarg.h>
#include <stdio.h>
int vsnprintf(char * restrict s, size_t n,
     const char * restrict format,
     va_list arg);

Description

2

The vsnprintf function is equivalent to snprintf, with the variable argument list replaced by arg, which shall have been initialized by the va_start macro (and possibly subsequent va_arg calls). The vsnprintf function does not invoke the va_end macro.[1] If copying takes place between objects that overlap, the behavior is undefined.

Returns

3

The vsnprintf function returns the number of characters that would have been written had n been sufficiently large, not counting the terminating null character, or a negative value if an encoding error occurred. Thus, the null-terminated output has been completely written if and only if the returned value is nonnegative and less than n.

Footnotes