vprintf - C stdio.h

C examples for stdio.h:vprintf

Type

function

From


<cstdio>
<stdio.h>

Description

Print formatted data from variable argument list to stdout

Prototype

int vprintf ( const char * format, va_list arg );

Parameters

ParameterDescription
format format string
arg a variable arguments list

Return Value

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

On error, the error indicator (ferror) is set and a negative number is returned.

Demo Code


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

Related Tutorials