Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ vprintf(3S) — DG/UX R4.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought



vprintf(3S)                       SDK R4.11                      vprintf(3S)


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 valist 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
       valist.  This argument is used with the stdarg.h header file macros
       vastart, vaarg and vaend [see vastart, vaarg, and vaend in
       stdarg(5)].  The USAGE section shows their use with vprintf.

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

   Considerations for Threads Programming
                     +---------+-----------------------------+
                     |         |                      async- |
                     |function | reentrant   cancel   cancel |
                     |         |             point     safe  |
                     +---------+-----------------------------+
                     |vfprintf |     Y         Y        N    |
                     |vprintf  |     Y         Y        N    |
                     |vsprintf |     Y         N        N    |
                     +---------+-----------------------------+

USAGE
       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(functionname, format, arg1, . . .);
               */
              void error(char *functionname, char *format, ...)
              {
                  valist ap;
                  vastart(ap, format);
                  /* print out name of function causing error */
                  (void) fprintf(stderr, "ERR in %s: ", functionname);
                  vaarg(ap, char*);
                  /* print out remainder of message */
                  (void) vfprintf(stderr, format, ap);
                  vaend(ap);
                  (void) abort;
              }

REFERENCES
       reentrant(3), printf(3S), stdarg(5)


Licensed material--property of copyright holder(s)

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