va_arg

Is a macro that obtains the next argument in a list of variable arguments.

Library:LibC
Classification:ANSI
Service:General C Services

Syntax

  #include <stdarg.h> 
   
  type va_arg (
    param,   
    type);
  

Parameters

param

(IN) Specifies a variable argument list.

type

(IN) Specifies the argument type.

Return Values

Returns the value of the next variable argument, according to type passed as the second parameter.

Remarks

The macro va_arg can be used to obtain the next argument in a list of variable arguments. It must be used with the associated macros va_start and va_end. A sequence such as the following:

     va_list curr_arg; 
     type next_arg; 
     next_arg = va_arg (curr_arg, type);
  

causes next_arg to be assigned the value of the next variable argument. The type is the type of the argument originally passed.

The macro va_start must be executed first in order to properly initialize the variable next_arg and the macro va_end should be executed after all arguments have been obtained.

The data item curr_arg is of type va_list which contains the information to permit successive acquisitions of the arguments.

See Also