Writes formatted output to stdout.
#include <stdio.h> int vprintf(const char *format, va_list arg);
format
A pointer to a format string.
arg
An argument list.
The vprintf() function works identically to the printf() function. Instead of the variable list of arguments that can be passed to printf(), vprintf() accepts its arguments in the array of type va_list processed by the va_start() macro from the stdarg.h header file.
vprintf() returns the number of characters written or a negative value if it failed.
This facility may not be available on configurations of the EWL that run on platforms without file systems.
#include <stdio.h> #include <stdarg.h> int pr(char *, ...); int main(void) { int a = 56; double f = 483.582; static char s[] = "Valerie"; // output a variable number of arguments to stdout pr("%15s %4.4f %-10d*\n", s, f, a); return 0; } // pr() formats and outputs a variable number of arguments // to stdout using the vprintf() function int pr(char *format, ...) { va_list args; int retval; va_start(args, format); // prepare the arguments retval = vprintf(format, args); va_end(args); // clean the stack return retval; } Output: Valerie 483.5820 56 *