Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ vsprintf(3S) — sys5 — Apollo Domain/OS SR10.4.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

printf(3S)

varargs(5)

fprintf(3S)

VPRINTF(3S)                          SysV                          VPRINTF(3S)



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

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

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

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

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

DESCRIPTION
     vprintf, vfprintf, and vsprintf are the same as printf, fprintf, and
     sprintf respectively, except that the variable argument list is replaced
     by ap, which must have been initialized by the va_start macro (and
     possibly subsequent va_arg calls). These functions do not invoke the
     va_end macro.

     In the case of vsprintf, if copying takes place between objects that
     overlap, the behavior is undefined.  For vfprintf and vprintf functions,
     the st_ctime and st_mtime fields of the file associated with stream is
     marked for update between the successful completion of these functions
     and the next successful completion of a call to fflush(3S) or fclose(3S)
     on the same stream or a call to exit(2) or abort(2).

DIAGNOSTICS
     These functions return the number of bytes written in the array, or a
     negative value if an output error occurred.

ERRORS
     The vprintf and vfprintf functions fail if either the stream is
     unbuffered, or the stream's buffer needed to be flushed and the function
     call caused an underlying write(2) or lseek(2) to be invoked.  In
     addition, if these functions fail, errno is set to one of the following
     values:

     [EAGAIN]       The O_NONBLOCK flag is set for the file descriptor
                    underlying stream and the process would be delayed in the
                    write operation.

     [EBADF]        The file descriptor underlying stream is not a valid file
                    descriptor open for writing.

     [EFBIG]        An attempt was made to write to a file that exceeds the
                    process' file size limit or the maximum file size.

     [EINTR]        The read operation was interrupted by a signal which was
                    caught, and no data was transferred.

     [EIO]          The implementation supports job control, the process is a
                    member of a background process group attempting to write
                    to its controlling terminal, TOSTOP is set, the process is
                    neither ignoring nor blocking SIGTTOU and the process
                    group of the process is orphaned.  This error may also be
                    returned under implementation-defined conditions.

     [ENOSPC]       There was no free space remaining on the device containing
                    the file.

     [EPIPE]        An attempt was made to write to a pipe or FIFO that is not
                    open for reading by any process.  A SIGPIPE signal will
                    also be sent to the process.

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

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

     void error(char *function_name, char *format, ...)

     {
          va_list args;

          va_start(args, format);

          /*print out name of function causing error */

          fprintf(stderr, "ERROR in %s: ", function_name);

          /* print out remainder of message */

          vfprintf(stderr, format, args);

          va_end(args);

     }


SEE ALSO
     printf(3S), varargs(5), fprintf(3S), <stdio.h>, <stdarg.h>.

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