Parameterized Macros

To form a parameterized macro:

#define identifier(parameterlist) replacement-list

There must be no spaces between the identifier and the parameter list. There must be no spaces in the parameter list. Parameterized macros often serve as simple functions.

Examples of parameterized macros:

#define getchar() getc(stdin)
#define max(x,y) (((x)>(y))?(x):(y))
#define toupper(c) (('a'<=(c)&&(c)<='z')?(c)-'a'+'A':(c))
Advantages of using a parameterized macro instead of a function:
Disadvantages of using a parameterized macro instead of a function:
Parameterized macros can be used to create templates for commonly used segments of code:

#define print(x) printf("%d\n",x)

print(i/j) /* becomes printf("%d\n",i/j); */