NAME

vprintf, vfprintf, vsprintf - print formatted output

SYNOPSIS

#include <stdio.h>

int vprintf (const char *format, __va_list);
int vfprintf (FILE *strm, const char *format, __va_list);
int vsprintf (char *s, const char *format, __va_list);

DESCRIPTION

The vprintf(), vfprintf(), and vsprintf() functions are equivalent to printf(), fprintf()and sprintf() respectively, except that instead of being called with a variable number of arguments, they are called with an argument list as defined by <stdarg.h>.

vprintf() places output on the standard output stream stdout .

vfprintf() places output on strm.

vsprintf() places output, followed by the null character (0), in consecutive bytes starting at s. It is the user's responsibility to ensure that enough storage is available.

Each function returns the number of characters transmitted (not including the 0 in the case of vsprintf()) ) or a negative value if an output error was encountered.

Characters generated by vprintf() and vfprintf() are printed as if the fputc() routine had been called.

RETURN VALUES

Refer to fprintf().

ERRORS

Refer to fprintf().

EXAMPLES

#include <stdio.h>
#include <stdarg.h>

  
void print_message(char *format, ...)
  {
    va_list ptr;

    va_start(ptr, format);

    vprintf(format, ptr);

    va_end(ptr);
  }

  
int main(void)
  {
    print_message("Cannot open file %s.", "test");

    
return 0;
  }

SEE ALSO

fprintf(), fputc()


< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2011 >