Often I see a function declared like this:
void Feeder(char *buff, ...)
what does \"...\" mean?
Functions with ...
as last parameter are called Variadic functions (Cppreference. 2016). This ...
is used to allow variable length parameters with unspecified types.
We can use variadic functions when we are not sure about the number of parameters or their types.
Example of variadic function: Let us assume we need a sum function that will return the summation of variable number of arguments. We can use a variadic function here.
#include
#include
int sum(int count, ...)
{
int total, i, temp;
total = 0;
va_list args;
va_start(args, count);
for(i=0; i
Output:
Practice problem: A simple problem to practice variadic function can be found in hackerrank practice problem here
Reference: