vprintf(3) — Subroutines
NAME
vprintf, vfprintf, vsprintf − Formats a variable number of parameters for output
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdio.h>
#include <stdarg.h>
int vprintf(
const char ∗format,
va_list printarg);
int vfprintf(
FILE ∗stream,
const char ∗format,
va_list printarg);
int vsprintf(
char ∗string,
const char ∗format,
va_list printarg);
PARAMETERS
formatSpecifies a character string that contains two types of objects:
•Plain characters, which are copied to the output stream.
•Conversion specifications, each of which causes zero or more items to be fetched from the stdarg parameter lists.
printargSpecifies the arguments to be printed.
streamSpecifies the output stream.
stringSpecifies the buffer to which output is printed.
DESCRIPTION
The vprintf(), vfprintf(), and vsprintf() functions format and write stdarg parameter lists.
These functions are the same as the printf(), fprintf(), and sprintf() functions, respectively, except that these functions are not called with a variable number of parameters. Instead, vprintf(), vfprintf(), and vsprintf() are called with a parameter list pointer as defined by stdarg.
NOTES
AES Support Level:
Full use.
EXAMPLES
The following example demonstrates how the vfprintf() function can be used to write an error routine:
#include <stdio.h>
#include <stdarg.h>
void error(char ∗funct, char ∗fmt, ...)
{
va_list args;
/∗
∗∗ Display the name of the function that called error
∗/
fprintf(stderr, "ERROR in %s: ", funct);
/∗
∗∗ Display the remainder of the message
∗/
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
abort();
}
RELATED INFORMATION
Functions: printf(3).