Demonstration of using Variable number of argument
#include
#include
main()
{
int add( int nint, ... );
printf ("Sum of 4 numbers is %d", add( 4, 1,2,3,4) );
printf ("Sum of 2 numbers is %d", add( 2, 10, -2 ));
}
int add ( int nint, ... )
{
va_list va;
int total = 0 ;
va = va_start (nint );
while ( nint-- )
total += va_next ( va, int ) ;
va_end (va );
return total ;
}