phrasing is mixed, resulting in names such as variadic variable (synonymous to hedge). Note the double meaning of the word variable and the difference between arguments and variables in functional programming and term rewriting. For example, a term (function) can have three variables, one of them a hedge, thus allowing the term to take three or more arguments (or two or more if the hedge is allowed to be empty). Examples In C To portably implement variadic functions in the C programming language, the standard header file is used. The older header has been deprecated in favor of . In C++, the header file is used. #include <stdarg.h> #include <stdio.h> double average(int count, ...) { va_list ap; int j; double sum = 0; va_start(ap, count); /* Before C23: Requires the last fixed parameter (to get the address) */ for (j = 0; j < count; j++) { sum += va_arg(ap, int); /* Increments ap to the next argument. */ } va_end(ap); return sum / count; } int main(int argc, char const *argv[]) { printf("%f\n", average(3, 1, 2, 3)); return 0; } This will compute the average of an arbitrary number of arguments. Note that the function does not know the number of arguments or their types. The above function expects that the types will be , and that the number of arguments is passed in the first argument (this is a frequent usage but by no means enforced by the language or compiler). In some other cases, for example printf, the number and types of arguments are figured out from a format string. In both cases, this depends on the programmer to supply the correct information. (Alternatively, a sentinel value like may be used to indicate the number.) If fewer arguments are passed in than the function believes, or the types of arguments are incorrect, this could cause it to read into invalid areas of memory and can lead to vulnerabilities like the format string attack. declares a type, , and defines four macros: , , , and . Each invocation of and must be matched by a corresponding invocation of . When working with variable arguments, a function normally declares a variable of type ( in the example) that will be manipulated by the macros. takes two arguments, a object and a reference to the function's last parameter (the one before the ellipsis; the macro uses this to get