vprintf(3) CLIX vprintf(3)
NAME
vprintf, vfprintf, vsprintf - Displays formatted output of a varargs
argument list
LIBRARY
Standard C Library libc.a.
SYNOPSIS
#include <stdio.h>
#include <varargs.h>
int vprintf(
char *format ,
va_list arg );
int vfprintf(
FILE *stream ,
char *format ,
va_list arg );
int vsprintf(
char *s ,
char *format ,
va_list ap );
PARAMETERS
arg A variable argument list
format A format string
s A character string
stream An output stream
DESCRIPTION
The vprintf(), vfprintf(), and vsprintf() functions are the same as
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 varargs.
EXAMPLES
The following uses vfprintf() to write an error function:
#include <stdio.h>
2/94 - Intergraph Corporation 1
vprintf(3) CLIX vprintf(3)
#include <varargs.h>
.
.
.
/*
* error should be called like
* error(function_name, format, arg1, arg2 ...);
*/
/*VARARGS*/
void
error(va_alist)
/* Note that the function_name and format arguments cannot be
* separately declared because of the definition of varargs.
*/
va_dcl
{
va_list args;
char *fmt;
va_start(args);
/* print out name of function causing error */
(void)fprintf(stderr, "ERROR in %s: ", va_arg(args, char *));
fmt = va_arg(args, char *);
/* print out remainder of message */
(void)vfprintf(stderr, fmt, args);
va_end(args);
(void)abort();
}
RETURN VALUES
Returns the number of characters transmitted or a negative value if an
error occurs.
RELATED INFORMATION
Functions: printf(3)
Miscellany: varargs(0)
2 Intergraph Corporation - 2/94