Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     VPRINTF(S)                UNIX System V                VPRINTF(S)



     Name
          vprintf, vfprintf, vsprintf - print formatted output of a
          varargs argument list

     Syntax
          #include <stdio.h>
          #include <varargs.h>

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

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

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

     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(S).

     Example
          The following demonstrates the use of vfprintf to write an
          error routine.

          #include <stdio.h>
          #include <varargs.h>
               ...
          /*
           *   error should be called by:
           *      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( );
          }

     See Also
          printf(S), varargs(S)

     Standards Conformance
          vfprintf, vprintf and vsprintf are conformant with:
          AT&T SVID Issue 2, Select Code 307-127;
          The X/Open Portability Guide II of January 1987;
          and ANSI X3.159-198X C  Language  Draft  Standard,  May  13,
          1988.
                                                (printed 6/20/89)



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