Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ vprintf(3S) — svr4 — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

printf(3S)

stdarg(5)



VPRINTF(3S-SVR4)    RISC/os Reference Manual     VPRINTF(3S-SVR4)



NAME
     vprintf, vfprintf, vsprintf - print formatted output of a
          variable argument list

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

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

     int vsprintf(char *s, const char *format, valist 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 the <stdarg.h>
     header file.

     The <stdarg.h> header file defines the type va_list and a
     set of macros for advancing through a list of arguments
     whose number and types may vary.  The argument ap to the
     vprint family of routines is of type va_list.  This argument
     is used with the <stdarg.h> header file macros va_start,
     va_arg and va_end [see va_start, va_arg, and va_end in
     stdarg(5)].  The EXAMPLE section below shows their use with
     vprintf.

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

          #include <stdio.h>
          #include <stdarg.h>
          /*
           *   error should be called like
           *         error(function_name, format, arg1, ...);
           */
          void error(char *function_name, char *format, ...)
          {
              va_list ap;

              va_start(ap, format);
              /* print out name of function causing error */
              (void) fprintf(stderr, "ERR in %s: ", function_name);
              va_arg(ap, char*);
              /* print out remainder of message */
              (void) vfprintf(stderr, format, ap);
              va_end(ap);
              (void) abort;
          }



                        Printed 11/19/92                   Page 1





VPRINTF(3S-SVR4)    RISC/os Reference Manual     VPRINTF(3S-SVR4)



SEE ALSO
     printf(3S), stdarg(5).

DIAGNOSTICS
     vprintf and vfprintf return the number of characters
     transmitted, or return -1 if an error was encountered.

















































 Page 2                 Printed 11/19/92



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