Is there a command which it finds the maximum of numbers? like MAX(A,B) in fortran
Is there a command which it finds the maximum of numbers? like MAX(A,B) in fortran
No, but you would write one pretty easily. See here: http://cboard.cprogramming.com/showthread.php?t=96236
Todd
Actually, I'm pretty sure there is a macro somewhere in a standard header that does MAX(a, b) of integer/float vaues.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
thanx for the fast replies!i will make a search
You can do this as a macro or as a function. There are downsides to both. The macro will evaluate its arguments multiple times. The function has call overhead. Two versions
Code:#define MY_MAX(a, b) ((a)>=(b)?(a):(b))The best of both worlds is an inline function, if your compiler supports it. It is usually a bad idea to name a macro "MAX" or "MIN", since many system headers on various platforms define these macros themselves.Code:int my_max(int a, int b) { return a>=b?a:b; }