Mega Code Archive

 
Categories / C / Macro Preprocessor
 

Use Macro to get the bigger int value

#include <stdio.h> #define MAX(i, j) i>j ? i : j int main(void) {   printf("%d\n", MAX(3, 2));   printf("%d\n", MAX(1, -1));   /* this statement does not work correctly */   printf("%d\n", MAX(100 && -1, 0));   return 0; }