{{keywords>wiki library source code example reference}} type va_arg(va_list ap, type); === description === The va_arg() macro expands to an expression that has the type and value of the next argument in the call. The argument ap is the va_list ap initialized by va_start(). Each call to va_arg() modifies ap so that the next call returns the next argument. The argument type is a type name specified so that the type of a pointer to an object that has the specified type can be obtained simply by adding a * to type. The first use of the va_arg() macro after that of the va_start() macro returns the argument after last. Successive invocations return the values of the remaining arguments. If there is no next argument, or if type is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), random errors will occur. If ap is passed to a function that uses va_arg(ap,type) then the value of ap is undefined after the return of that function. The [[c:stdarg.h:va_start|va_start()]], [[c:stdarg.h:va_arg|va_arg()]], and [[c:stdarg.h:va_end|va_end()]] macros conform to C89. C99 defines the [[c:stdarg.h:va_copy|va_copy()]] macro.