Home > Back-end >  C language pretreatment
C language pretreatment

Time:11-20

Why did the (M + 1) * M=9, bosses, o NUM is equal to 8, guide
#include
# define N 2
# define M N + 1
# define NUM (M + 1) * M/2
The main ()
{
Printf (" % d \ n ", M);
Printf (" % d \ n ", M + 1);
Printf (" % d \ n ", (M + 1) * M);
Printf (" % d \ n ", NUM);

CodePudding user response:


macro definition is equivalent to replace?M==(M + 1) * (N + 1 + 1) * N + 1==(2 + 1 + 1) * 2 + 1=9

CodePudding user response:

The
reference 1/f, confident boy reply:

macro definition is equivalent to replace?M==(M + 1) * (N + 1 + 1) * N + 1==(2 + 1 + 1) * 2 + 1=9

Macro definition to add parentheses is important, otherwise won't calculate ~ as you expected

CodePudding user response:

VC compiler options/EP/P (projects, properties, configuration properties, C/C + +, the preprocessor, pretreatment to the file: is that the preprocessing cancel display line Numbers: is), recompile, view the corresponding after macro expansion. I file, GCC - E http://bbs.csdn.net/topics/391003898

CodePudding user response:

The same code I have seen dozens of posts
  • Related