How do I loop through a va_list if the number of additional arguments is unknown?
#include
#include
int add(int x, int y, ...
You probably want to do something like pass the number of arguments as the first parameter.
E.g. see here: http://www.cplusplus.com/reference/clibrary/cstdarg/va_start/
And more discussion here: http://www.learncpp.com/cpp-tutorial/714-ellipses-and-why-to-avoid-them/
Variable arguments can be hazardous so if at all possible I'd try to avoid them. Passing a "vector" type which includes size and a pointer to the element array would be safer.