.\" @(#)varargs.3 6.3 (Berkeley) 5/15/86
.TH VARARGS 3 "May 15, 1986"
varargs \- variable argument list
.B "#include <varargs.h>"
This set of macros provides a means of writing portable procedures that
accept variable argument lists.
Routines having variable argument lists (such as
that do not use varargs are inherently nonportable, since different
machines use different argument passing conventions.
is used in a function header to declare a variable argument list.
Note that there is no semicolon after
is a type which can be used for the variable
which is used to traverse the list.
One such variable must always be declared.
to the beginning of the list.
will return the next argument in the list pointed to by
is the type to which the expected argument will be converted
when passed as an argument.
In standard C, arguments that are
arguments are converted to
Different types can be mixed, but it is up
to the routine to know what type of argument is
expected, since it cannot be determined at runtime.
Multiple traversals, each bracketed by
\fB#include\fP <varargs.h>
file = \fBva_arg(ap, \fBchar\fP *);
\fBwhile\fP (args[argno++] = \fBva_arg\fP(ap, \fBchar\fP *))
\fBreturn\fP execv(file, args);
It is up to the calling routine to determine how many arguments
there are, since it is not possible to determine this from the
stack frame. For example,
passes a 0 to signal the end of the list.
can tell how many arguments are supposed to be there by the format.
may be arbitrarily complex;
might contain an opening brace,
which is closed by a matching brace in
Thus, they should only be used where they could
be placed within a single complex statement.