Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

printf(3S)

setlocale(3C)

varargs(5)

vprintf(3S)

NAME

vprintf(), vfprintf(), vsprintf() − print formatted output of a varargs argument list

SYNOPSIS

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

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

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

int vsprintf(char *s, const char *format, va_list ap);

DESCRIPTION

vprintf(), vfprintf(), and vsprintf() 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 <stdarg.h>. 

EXAMPLE

The following demonstrates how vfprintf() could be used to write an error routine:

#include <stdarg.h>
#include <stdio.h>
    .
    .
    .
/*
 *  error should be called using the form:
 *      error(function_name, format, arg1, arg2...);
 */
 /*VARARGS0*/
void
error(va_alist)
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( );
}

SEE ALSO

printf(3S), setlocale(3C), varargs(5). 

STANDARDS CONFORMANCE

vprintf(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

vfprintf(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

vsprintf(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Hewlett-Packard Company  —  HP-UX Release 10.20:  July 1996

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026