C examples for stdio.h:vfprintf
function
<cstdio> <stdio.h>
Write formatted data from variable argument list to stream
int vfprintf ( FILE * stream, const char * format, va_list arg );
Parameter | Description |
---|---|
stream | FILE object. |
format | a format string. |
arg | a variable arguments list. |
On success, the total number of characters written is returned.
#include <stdio.h> #include <stdarg.h> void WriteFormatted (FILE * stream, const char * format, ...) { va_list args;/*from w w w. java 2s. c o m*/ va_start (args, format); vfprintf (stream, format, args); va_end (args); } int main () { FILE * pFile; pFile = fopen ("main.cpp","w"); WriteFormatted (pFile,"%d .\n",1); WriteFormatted (pFile,"%d %s.\n",2,"arguments"); fclose (pFile); return 0; }