<stdarg.h> header file declares a type and defines
three macros for advancing through a list of function arguments of
varying number and type.
To access varying arguments, the called function must declare an
object (referred to as ap in this section) that has the
The object ap can be passed as an argument to another
function. If that function invokes the
with parameter ap, the value of ap in the
calling function is indeterminate and is passed to the
end macro before any further reference to ap.
void va_start(va_list ap, parmN);
va_startmacro must be invoked before any access to the unnamed arguments.
The parameter parmN is the identifier of the
rightmost parameter in the variable parameter list of the
function definition. If parmN is declared with the
register storage class, with a function or array
type, or with a type that is not compatible with the type that
results after application of the default arguments promotions,
the behavior is undefined. The
returns no value.
type va_arg(va_list ap,
va_listap that was initialized by
va_start. Each invocation of
va_argmodifies ap so that the values of successive arguments are returned in turn. The parameter type is a type name specified such that the type of a pointer to an object that has the specified type can be obtained by postfixing an asterisk (*) to type. The behavior is undefined if there is no actual next argument, or if type is not compatible with the type of the next actual argument (as promoted according to the default argument promotions).
The first invocation of
va_arg after that of
va_start returns the value of the argument after
that specified by parmN. Successive invocations return
the values of the remaining arguments in turn.
void va_end(va_list ap);
va_startthat initialized the
va_listap object. The
va_endmacro can modify ap so that it can no longer be used (without an intervening invocation of
va_start). If there is no corresponding invocation of
va_ endis not invoked before the return, the behavior is undefined. The
va_endmacro returns no value.