A variadic function places an ellipsis (...) after its known parameters, allowing a call to provide an arbitrary number of additional arguments. The declaration of printf illustrates the pattern: int printf(char const format[static 1], ...). section 17.4 section 17.4.2
Treat the ellipsis as a flexible but weakly checked interface:
- Apply the default argument promotions: narrow integer types such as char and short usually become int, and float becomes double. section 17.4.2 section 18.1.4
- Provide an independent convention that tells the callee each argument's type; the ellipsis itself does not preserve that information for checking. section 17.4.2
- Keep the call and the convention consistent, because incorrect format specifications or argument types can cause portability and safety problems. section 7.1 section 18.1.4
Format strings supply the missing type information
In printf("%hhu", zChar), zChar is promoted to int before the call, while %hhu tells printf to interpret the received value as unsigned char. A mismatched specification, such as printf("%d: %s\n", 65536, "a small number"), is not portable. 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 va_list operations provide the basic interface for traversing variadic arguments: initialize with va_start, retrieve with va_arg, finish with va_end, and copy with va_copy. section 17.4.2







