variable number of arguments
Posted on 1998-10-14
I've got this function (ripped from the VC++ help :-) to add a variable number of integer together. Problem is : I don't like to add that last argument to close the list. Is there a way around this unprofessional looking thing.
int add(int first, ...)
int i, count = first;
while((i = va_arg(argp, int)) != 0)
count += i;
add(19, 27, 16, 36, 5, 4, 0);
// add(19, 27, 16, 36, 5, 4); this is what I want.