In a C function declaration, what does "..." as the last parameter do? In a C function declaration, what does "..." as the last parameter do? c c

In a C function declaration, what does "..." as the last parameter do?


it allows a variable number of arguments of unspecified type (like printf does).

you have to access them with va_start, va_arg and va_end

see http://publications.gbdirect.co.uk/c_book/chapter9/stdarg.html for more information


Variadic functions

Variadic functions are functions which may take a variable number of arguments and are declared with an ellipsis in place of the last parameter. An example of such a function is printf.

A typical declaration is

    int check(int a, double b, ...);

Variadic functions must have at least one named parameter, so, for instance,

    char *wrong(...);  

is not allowed in C.


The three dots '...' are called an ellipsis. Using them in a function makes that function a variadic function.To use them in a function declaration means that the function will accept an arbitrary number of parameters after the ones already defined.

For example:

Feeder("abc");Feeder("abc", "def");

are all valid function calls, however the following wouldn't be:

Feeder();