I want to write a function which takes at least two integer and returns the sum of all integer passed to the function:
int sumOfAtLeastTwoIntegers(int a, int b, ...){
int sum = a+b;
va_list ptr;
va_start(ptr,b);
for(){
sum += va_arg(ptr, int)
}
va_end(ptr);
return sum;
}
Run Code Online (Sandbox Code Playgroud)
I want to know how the expression in the for loop has to look like such that the loop continues until all optional arguments were added to the sum. How would I achieve this …