...
at the end of a function's parameter list says that the function takes a variable number of arguments. I'll leave it at that so you can try to figure out why it works, then I can tell you how it works. :)
One thing to note though is that the variable arguments are not type checked. Hence why printf
(which is a variable argument function) uses the format string to determine the type of the argument.
As for when to use it...rarely, in my experience. The negatives tend to outweight the positives, but if you have a situation like printf
or scanf
, then variable parameters can be a useful solution.