You are viewing a single comment's thread. Return to all comments →
No need to make it too complicated, you know:
int sum (int count,...) { int ret = 0; va_list args; va_start(args, count); for(int i=0; i<count; i++){ ret += va_arg(args, int); } return ret; } int min(int count,...) { int ret = 999999999; va_list args; va_start(args, count); for(int i=0; i<count; i++){ int temp = va_arg(args, int); if (temp<ret){ ret = temp; } } return ret; } int max(int count,...) { int ret = -999999999; va_list args; va_start(args, count); for(int i=0; i<count; i++){ int temp = va_arg(args, int); if (temp>ret){ ret = temp; } } return ret; }
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 →
No need to make it too complicated, you know: