Synopsis
type va_arg(va_list ap,
            type);
Description

va_arg expands to an expression that has the specified type and the value of the type argument. The ap parameter must have been initialized by va_start or va_copy, without an intervening invocation of va_end. You can create a pointer to a va_list and pass that pointer to another function, in which case the original function may make further use of the original list after the other function returns.

Each invocation of the va_arg macro modifies ap so that the values of successive arguments are returned in turn. The parameter type must be a type name such that the type of a pointer to an object that has the specified type can be obtained simply by postfixing a * to type.

If there is no actual next argument, or if type is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior of va_arg is undefined, except for the following cases:

The first invocation of the va_arg macro after that of the va_start macro returns the value of the argument after that specified by parmN. Successive invocations return the values of the remaining arguments in succession.