vprintf
, vfprintf
, vsprintf
---format argument list#include <stdio.h> #include <stdarg.h> int vprintf(const char *fmt, va_list list); int vfprintf(FILE *fp, const char *fmt, va_list list); int vsprintf(char *str, const char *fmt, va_list list); int _vprintf_r(void *reent, const char *fmt, va_list list); int _vfprintf_r(void *reent, FILE *fp, const char *fmt, va_list list); int _vsprintf_r(void *reent, char *str, const char *fmt, va_list list);Description
vprintf
, vfprintf
, and vsprintf
are (respectively)
variants of printf
, fprintf
, and sprintf
. They differ
only in allowing their caller to pass the variable argument list as a
va_list
object (initialized by va_start
) rather than directly
accepting a variable number of arguments.
Returns
The return values are consistent with the corresponding functions:
vsprintf
returns the number of bytes in the output string,
save that the concluding NULL
is not counted.
vprintf
and vfprintf
return the number of characters transmitted.
If an error occurs, vprintf
and vfprintf
return EOF
. No
error returns occur for vsprintf
.
Portability
ANSI C requires all three functions.
Supporting OS subroutines required: close
, fstat
, isatty
,
lseek
, read
, sbrk
, write
.