You are viewing a single comment's thread. Return to all comments →
int sum (int count,...) { int i, sum; va_list op; va_start(op, count); i = sum = 0; for (; i < count; i++) sum += va_arg(op, int); va_end(op); return (sum); } int min(int count,...) { int i, min, value; va_list op; va_start(op, count); i = 0; min = va_arg(op, int); for (; i < count; i++) { value = va_arg(op, int); min = value > min ? min : value; } va_end(op); return (min); } int max(int count,...) { int i, max, value; va_list op; va_start(op, count); i = 0; max = va_arg(op, int); for (; i < count; i++) { value = va_arg(op, int); max = value < max ? max : value; } va_end(op); return (max); }
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 →