.TH vprintf() "" "" "STDIO Function (libc)"
.PC "Print formatted text into standard output stream"
.B "#include <stdarg.h>"
.B "#include <stdio.h>"
\fBint\fR
\fBvprintf(\fIformat\^\fB, \fIarguments\^\fB)\fR
\fBchar *\fIformat\^\fB; va_list \fIarguments\^\fB;\fR
.PP
.II "standard output stream^print formatted text"
.II "text^print formatted into stream"
.B vprintf()
constructs a formatted string and writes it into the standard output stream.
It translates integers, floating-point numbers, and strings
into a variety of text formats.
.B vprintf
can handle a variable list of arguments of various types.
It is roughly equivalent to \fBprintf()\fR's conversion specifier
.BR %r .
.PP
.I format
points to a string that can contain text, character constants, and one or
more \fIconversion specifications\fR.
A conversion specification defines how a
particular data type is converted into a particular text format.
Each conversion specification is introduced with the
percent sign `%'.
(To print a literal percent sign, use the escape sequence `%%'.)
See
.B printf()
for further discussion of the conversion specification and for a
table of the type specifiers that can be used with
.BR vprintf() .
.PP
After
.I format
comes
.IR arguments .
This is of type
.BR va_list ,
which is defined in the header
.BR stdarg.h .
It has been initialized by the macro
.B va_start()
and points to the base of the list of arguments
used by
.BR vprintf() .
Each argument must have basic type
that can be converted to a pointer simply by adding an `*' after the type name.
This is the same restriction that applies to the arguments to the macro
.BR va_arg() .
For more information, see
.BR va_arg() .
.PP
.I arguments
should access one argument for each conversion specification in
.I format
of the type appropriate to conversion specification.
For example, if
.I format
contains conversion specifications for an
.BR int ,
a
.BR long ,
and a string, then
.I arguments
access three arguments, being, respectively,
an
.BR int ,
a
.BR long ,
and a
.BR "char *" .
.PP
If there are fewer arguments than conversion specifications, then
.BR vprintf 's
behavior is undefined (and probably unwelcome).
If there are more, then
.B vprintf()
evaluates and then ignores
every argument without a corresponding conversion specification.
If an argument is not of the same type as its corresponding type
specification, then the behavior of
.B vprintf()
is undefined; thus, accessing an
.B int
where
.B vprintf()
expects a
.B "char *"
may generate unwelcome results.
.PP
If it writes the formatted string correctly,
.B vprintf()
returns the number of characters written;
otherwise, it returns a negative number.
.SH "See Also"
.Xr "fprintf()," fprintf
.Xr "libc," libc
.Xr "printf()," printf
.Xr "sprintf()," sprintf
.Xr "vfprintf()," vfprintf
.Xr "vsprintf()" vsprintf
.br
\*(AS, \(sc7.9.6.8
.SH Notes
.B vprintf()
can construct a string up to at least 509 characters long.
.\".PP
.\"The character that
.\".B vprintf()
.\"uses to represent the decimal point is affected by the program's locale,
.\"as set by the function
.\".BR setlocale() .
.\"For more information, see
.\".BR localization .
