Variadic Functions

Learn about variadic functions.

We'll cover the following...

What are variadic functions?

A variadic function is one which accepts a variable number of input arguments. We can write functions that are variadic in C. Sometimes this may be useful. For example, the printf function which, as we’ve already seen, can accept a variable number of input arguments.

Here’s an example of a variadic function mean that computes the average of a variable-sized list of numbers. The ellipsis (...) in the parameter list indicate that the function can take any number of arguments. The ellipsis always appear at the end, and must be preceded by a named parameter (count in our case) to store the number of arguments passed to the function when it is called.