C examples for stdio.h:vprintf
function
<cstdio> <stdio.h>
Print formatted data from variable argument list to stdout
int vprintf ( const char * format, va_list arg );
Parameter | Description |
---|---|
format | format string |
arg | a variable arguments list |
On success, the total number of characters written is returned.
On error, the error indicator (ferror) is set and a negative number is returned.
#include <stdio.h> #include <stdarg.h> void WriteFormatted ( const char * format, ... ) { va_list args;// www. ja va 2 s . c o m va_start (args, format); vprintf (format, args); va_end (args); } int main () { WriteFormatted ("%d variable argument.\n",1); WriteFormatted ("%d variable %s.\n",2,"arguments"); return 0; }