unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

VPRINTF(3V)                                                        VPRINTF(3V)



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

SYNOPSIS
       #include <&lt;stdio.h>&gt;
       #include <&lt;varargs.h>&gt;

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

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

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

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

DESCRIPTION
       vprintf(), vfprintf(), and  vsprintf()  are  the  same  as  printf(3V),
       fprintf(),  and  sprintf()  (see  printf(3V)) respectively, except that
       instead of being called with a variable number of arguments,  they  are
       called with an argument list as defined by varargs(3).

RETURN VALUES
       On  success,  vprintf()  and vfprintf() return the number of characters
       transmitted, excluding the null character.   On  failure,  they  return
       EOF.

       vsprintf() returns s.

SYSTEM V RETURN VALUES
       vsprintf()  returns the number of characters transmitted, excluding the
       null character.

EXAMPLES
       The following demonstrates how vfprintf() could be  used  to  write  an
       error routine.
              #include <&lt;stdio.h>&gt;
              #include <&lt;varargs.h>&gt;
              ...
                   /*  error should be called like:
                   *    error(function_name, format, arg1, arg2...);
                   *  Note: function_name and format cannot be declared
                   *  separately because of the definition of varargs.
                   */
              /*VARARGS0*/
              void
              error (va_alist)
                   va_dcl
              {
                   va_list args;
                   char *fmt;

                   va_start(args);
                        /* print 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(3V), varargs(3)



                                21 January 1990                    VPRINTF(3V)