vfprintf - C stdio.h

C examples for stdio.h:vfprintf

Type

function

From


<cstdio>
<stdio.h>

Description

Write formatted data from variable argument list to stream

Prototype

int vfprintf ( FILE * stream, const char * format, va_list arg );

Parameters

ParameterDescription
stream FILE object.
format a format string.
arg a variable arguments list.

Return Value

On success, the total number of characters written is returned.

Demo Code


#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;
}

Related Tutorials