Ive seen some library functions that do it, but lets say...
How would you write a max() function that could take 2 or more parameters, without rewriting the function for 3 params, 4 params, 5 params, etc..?
Printable View
Ive seen some library functions that do it, but lets say...
How would you write a max() function that could take 2 or more parameters, without rewriting the function for 3 params, 4 params, 5 params, etc..?
look up va_list for more on how to handle variable number of parametersCode:int max (int num_para, ... ) {
// Stuff to do the compares for each item
return the_value_of_the_max_item;
}