C Standard Library - <stdarg.h>
Introduction
stdarg.h The header file defines a variable type va_list and three macros, which can be used in parameters Obtain the parameters in the function when the number of parameters is unknown (that is, the number of parameters is variable).
Variable parameter functions are usually defined using an ellipsis (,...) at the end of the parameter list.
Library variables
The following are the variable types defined in the header file stdarg.h:
Serial number | Variables & Description |
---|---|
1 | va_list This is a list for va_start(), va_arg() and va_end() The type of information these three macros store. |
Library macros
The following are the macros defined in the header file stdarg.h:
Serial number | Macro & Description |
---|---|
1 | void va_start(va_list ap, last_arg) This macro initializationap Variable, which is used together with the va_arg and va_end macros. last_arg is the last known fixed parameter passed to the function, that is, the parameter before the ellipsis. |
2 | type va_arg(va_list ap, type) This macro retrieves the next parameter of type type in the function parameter list . |
3 | void va_end(va_list ap) This macro allows the return of functions with variable parameters using the va_start macro . If va_end is not called before returning from the function, the result is undefined. |