.TH VARARGS 3 "19 January 1983"
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 the argument is expected to be.
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.