#include<stdio.h>
#include<stdarg.h>
int total(int one, ...);
int main()
{
printf("Total=%d\n",total(10,20,30,40,15,-1));
return 0;
}
int total(int one, ...)
{
int sum=0;
va_list ap;
va_start (ap, one);
sum=one;
while (*ap!=-1)
sum+=(va_arg(ap,int));
va_end(ap);
return sum;
}
Top