c querries
Now i can answer you the last question.
We can define a function that have indefinite parameters as input.
for this problem we can use the stdarg macros which defined in the stdarg.h head file. this head file has defined a type va_list and 3 macros --va_start, va_arg , va_end. we can declare a varibale of va_list type, and with the three macros to access the parameters.
/*
** Compute the average of the specified number of values.
*/
#include <stdarg.h>
float
average( int n_values, ... )
{
va_list var_arg;
int count;
float sum = 0;
/*
** Prepare to access the variable arguments.
*/
va_start( var_arg, n_values );
/*
** Add the values from the variable argument list.
*/
for( count = 0; count < n_values; count += 1 ){
sum += va_arg( var_arg, int );
}
/*
** Done processing variable arguments.
*/
va_end( var_arg );
return sum / n_values;
}
all of this you can refer to <pointers on c>by kenneth A.Reek chapter 7.6 .
(forgive my poor english)