va_start is a macro from <stdarg.h> that initializes a va_list with information about a variadic function’s hidden arguments. The initialized list can then be consumed by va_arg or passed to a library function such as vfprintf or vsnprintf. section 17.2 section 17.4.2
Initialize, forward, and finish a variable argument list
void trace(char const *format, ...) { va_list ap; va_start(ap, format); /* use the last named parameter */ vfprintf(stream, format, ap); va_end(ap); } Here va_start prepares ap without using the address operator. vfprintf performs the formatted-argument processing, while va_end closes the use of the list. Since C23, the second va_start argument may be omitted; traditionally it names the parameter immediately before the ellipsis. section 17.4.2
A variadic implementation commonly combines these <stdarg.h> operations:
- va_start initializes a va_list for the arguments hidden behind ... . section 17.4.2
- va_arg retrieves one value and requires its type explicitly; the implementation must track the list as values are consumed. section 17.4.2
- va_end completes the use of the initialized list, and va_copy provides a separate list copy when needed. section 17.4.2
- Prefer an existing formatted-output function when possible, rather than reproducing its argument analysis. section 17.2 section 17.4.2
void va_start(va_list ap, ...);
void va_end(va_list ap);
\textit{type} va_arg(va_list ap, \textit{type});
void va_copy(va_list dest, va_list src);
The compact interface listing places va_start, va_arg, va_end, and va_copy together, making their roles and signatures easy to compare. section 17.4.2

