我正在编写一个方法,它接受一个数字 n 和 n 个整数(一个变量数),这个函数将返回不包括 n 的整数的总和。我被困在如何单独访问每个参数上。这是我到目前为止所拥有的,我在网上阅读了它,希望我走在正确的轨道上。在网上找到的似乎有用的方法是:
va_start()
va_arg()
va_end()
int sumv(int n, ...)
{
va_list list;
int sum = 0;
while(n>0)
{
//*********************
//this is the part where I am stuck on, how do I get each paramater?
//I know it will be an int
//*********************
n--;
}
return sum;
}