An example of use of varargs in C
Here I found an example of how varargs can be used in C. #include <stdarg.h> double average(int count, ...) { va_list ap; int j; double tot = 0; va_start(ap, count); //Requires the last fixed parameter (to get the address) for(j=0; j<count; j++) tot+=va_arg(ap, double); //Requires the type to cast to. Increments ap to the next argument. va_end(ap); return tot/count; } I can understand this example only to some extent. It is not clear to me why we use va_start(ap, count); . As far as I understand, in this way we set the iterator to its first element. But why it is not set to the beginning by