...
Code Block |
---|
int average(int first, ...) { int count = 0; int sum = 0; int i = first; va_list marker; va_start(marker, first); while (i != -1) { sum += i; count++; i = va_arg(marker, int); } va_end(marker); return(sum ? (sum / count) : 0); } |
Note that va_start()
must always be called to initialize the argument list.
However, if the function is called as follows:
...