##### Synopsis

    #include <stdio_c.h>
    int vsnprintf_c(char *s, size_t n, __code const char *format, va_list arg);

##### Description

vsnprintf_c writes to the string pointed to by s under control of the string pointed to by format that specifies how subsequent arguments are converted for output. The format string is stored in flash (code) memory. Before calling vsnprintf_c, arg must be initialized by the va_start macro (and possibly subsequent va_arg calls). vsnprintf_c does not invoke the va_end macro.

If n is zero, nothing is written, and s can be a null pointer. Otherwise, output characters beyond the n-1st are discarded rather than being written to the array, and a null character is written at the end of the characters actually written into the array. A null character is written at the end of the conversion; it is not counted as part of the returned value.

If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while arguments remain, the excess arguments are evaluated but are otherwise ignored.

If copying takes place between objects that overlap, the behavior is undefined.

vsnprintf_c 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.

##### Notes

vsnprintf_c is equivalent to snprintf_c with the variable argument list replaced by arg.

##### Portability

vsnprintf_c is an extension provided by CrossWorks C.

##### See Also

Format strings for printf functions