gpt4 book ai didi

c - 宏观评价

转载 作者:行者123 更新时间:2023-12-02 05:41:04 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Undefined Behavior and Sequence Points

我无法理解以下宏:

#define CUBE(x) ((x)*(x)*(x))

我的代码:

int y=5;
print("Cube = %d",CUBE(++y));

这段代码打印出 512(使用 Microsoft Visual Studio)

我原以为会打印:((++5)*(++6)*(++7)) = (6*7*8) = 336
这是如何评估的?

同样的代码也是使用 Dev C++ 编译器编译的,结果是 392!!!

谁能解释为什么两个编译器对完全相同的代码显示不同的结果?

这个++y是如何计算的?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com