Problem with Macros
问题 HI , Can some one help me in understanding why the value of SQUARE(x) is 49 ? I am using Visual C++ 6.0 . #define SQUARE(X) X * X int main(int argc, char* argv[]) { int y = 5; printf("%d\n",SQUARE(++y)); return 0; } 回答1: Neil Butterworth, Mark and Pavel are right. SQUARE(++y) expands to ++y * ++y, which increments twice the value of y. Another problem you could encounter: SQUARE(a + b) expands to a + b * a + b which is not (a+b)*(a+b) but a + (b * a) + b. You should take care of adding