Variadic Functions

Learn about the 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 ellipses (...) in the parameter list indicate that the function can take any number of arguments. The ellipses 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.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy