A variadic function accepts a fixed parameter list followed by ..., then uses stdarg.h to access the hidden arguments through va_list. For formatted output, pass that list to vfprintf instead of parsing each argument manually. 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 core interface consists of va_list plus va_start, va_end, va_arg, and va_copy; initialize, retrieve, copy, and finally release argument-list state. section 17.4.2
Use the interface with explicit portability and correctness constraints:
- Initialize a va_list with va_start, retrieve arguments with va_arg, and finish with va_end. section 17.4.2
- Since C23, va_start may omit the traditional second argument naming the last parameter before .... section 17.4.2
- Do not rely on implicit conversions in variadic calls: each argument must be forced to the expected type for portable behavior. section 17.4.2
- Prefer existing formatted-printing functions and avoid designing new variadic interfaces when a non-variadic alternative is available. section 17.4.2
Forwarding a variable argument list
A wrapper around formatted output can create a va_list with va_start, pass it to vfprintf, and call va_end afterward. This avoids implementing argument-by-argument format handling. section 17.4.2
