为什么这段代码输出3
问题描述:
可能重复:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)为什么这段代码输出3
我发现这段代码,原来在这里:
#include <stdio.h>
int main()
{
int p = 0;
p = p++ + ++p;
printf("p=%d\n", p);
}
我猜输出将是2 ,但是当我编译代码并执行它时,输出为3,为什么?
http://*.com/questions/949433/could-anyone-explain-these-undefined-behaviors-iiiii-etc – Mysticial 2012-04-03 01:38:45
只是要确定:您是否在寻找对此输出的解释未定义的行为? – cctan 2012-04-03 01:42:07
阅读由编译器生成的汇编代码。 – 2012-04-03 01:44:10