Item Value
Header filestdarg.h stdio.h
Declarationint vprintf(char *format, va_list arg_ptr); int vfprintf(FILE *stream, const char *format, va_list arg_ptr); int vsprintf(char *buf, const char *format, va_list arg_ptr); int vsnprintf(char * restrict buf, size_t num, const char * restrict format, va_list arg_ptr);
The functions vprintf(), vfprintf(), vsprintf(), and vsnprintf() are functionally equivalent to
printf(), fprintf(), sprintf(), and snprintf(), respectively
, except that the argument list has been replaced by a pointer to a list of arguments.
This pointer must be of type va_list, which is defined in the header .
#include
#include
void print_message(char *format, ...)
{
va_list ptr;
va_start(ptr, format);
vprintf(format, ptr);
va_end(ptr);
}
int main(void)
{
print_message("Cannot open file %s.", "test");
return 0;
}