A macro is nothing more than another define, but since it is capable of at least appearing to perform some logical decisions or some math functions, it has a unique name. Consider the third line of the program on your screen for an example of a macro. In this case, anytime the preprocessor finds the word "MAX" followed by a group in parentheses, it expects to find two terms in the parentheses and will do a replacement of the terms into the second definition. Thus the first term will replace every "A" in the second definition and the second term will replace every "B" in the second definition. When line 12 of the program is reached, "index" will be substituted for every "A", and "count" will be substituted for every "B". Remembering the cryptic construct we studied a couple of chapters ago will reveal that "mx" will receive the maximum value of "index" or "count". In like manner, the "MIN" macro will result in "mn" receiving the minimum value of "index" or "count". The results are then printed out. There are a lot of seemingly extra, they are essential. We will discuss the extra parentheses in our next program.
Compiler and run define.c.
Compiler and run define.c.