/* ifdef.c -- uses conditional compilation */
#include
#define JUST_CHECKING
#define LIMIT 4
int main(void)
{
int i;
int total = 0;
for (i = 1; i <= LIMIT; i++)
{
total += 2*i*i + 1;
#ifdef JUST_CHECKING
printf("i=%d, running total = %d\n", i, total);
#endif
}
printf("Grand total = %d\n", total);
return 0;
}
它输出的值是这个
i=1,running total=3
i=2,running total=12
i=3,running total=31
i=4,running total=64
Grand total=64
为什么输出的不是这个呢?
i=1,running total=3
i=2,running total=9
i=3,running total=19
i=4,running total=33
Grand total=33
我用的编译器是VC6.0
这是 C primer Plus 第五版第16章 ifdef.c的例子 求解...