You need at least one real parameter, as you have in your example. Then you use some special macros to access the parameters:
void AddSomeNumbers( int howMany, .... ) // any number of 'real' params, folowed by ...
{
va_list argptr;
int ret = 0;
va_start( argptr, howMany ); // use the last 'real' param here
for (int i = 0; i < howMany; i++)
ret += va_arg( argptr, int ); // the next arg is an int, we hope
va_end(argptr);
return ret;
}
The caviats are:
1) You do not know how many parameters were supplied. Thats why in my sample I had that be the one 'real' parameter.
2) You do not know the type of parameters, so you have to 'guess' and hope the caller knows what they are doing!
printf() and its variants use this, and the format string specifies the number and type of parameters:
printf( "%s %d %x\n", "string", number, number );
but if you screw up you get fun results!
printf( "%s %d %d\n", number, "string", 1.2 ); // ick!