You are viewing a single comment's thread. Return to all comments →
int sum (int count,...) { va_list list; va_start(list, count); long sum = va_arg(list, int); for(int i = 1; i < count; i++){ sum+= va_arg(list, int); } va_end(list); return sum; } int min(int count,...) { va_list list; va_start(list, count); long min = va_arg(list, int); for(int i = 1; i < count; i++){ int tmp = va_arg(list, int); if(tmp < min) min = tmp; } va_end(list); return min; } int max(int count,...) { va_list list; va_start(list, count); long max = va_arg(list, int); for(int i = 1; i < count; i++){ int tmp = va_arg(list, int); if(tmp > max) max = tmp; } va_end(list); return max; } int test_implementations_by_sending_three_elements() {
Seems like cookies are disabled on this browser, please enable them to open this website
Variadic functions in C
You are viewing a single comment's thread. Return to all comments →