Initialization of variable for scanning argument list
[Classification]
Standard library
[Syntax]
#include <stdarg.h>
typedef char __near *va_list;
void va_start(va_list ap, last-named-argument);
[Description]
This function initializes variable ap so that it indicates the beginning (argument next to last-named-argument) of the list of the variable arguments.
To define function func having a variable arguments in a portable form, the following format is used.
#include <stdarg.h>
void func(arg-declarations, ...) {
va_list ap;
type argN;
va_start(ap, last-named-argument);
argN = va_arg(ap, type);
va_end(ap);
}
|
Remark | arg-declarations is an argument list with the last-named-argument declared at the end. ", ..." that follows indicates a list of the variable arguments. va_listis the type of the variable (ap in the above example) used to scan the argument list. |