<stdarg.h> Variable Argument Lists

The header file stdarg.h supports functions with variable argument lists.

Variable argument lists allow functions to have an arbitrary number of arguments without corresponding parameter declarations, thus, the number and type of these arguments can differ on each call to the function.

A function with a variable argument list must have at least one named argument. The arguments in the argument list are represented by an ellipsis, .... To read the argument list, an object of type va_list must be declared inside the function to hold information about the argument list. The va_start macro is used to initialize the va_list object so that the argument values can be obtained, the va_arg macro will access the next argument in the list, and the va_end macro ensures that the function is in a state whereby it can successfully return after all the required arguments have been read.