【发布时间】:2011-06-07 09:53:25
【问题描述】:
可能重复:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)
#include< stdio.h >
int main()
{
int i = 1;
int x = ++i * ++i * ++i;
printf("%d\n", x);
printf("%d\n\n",i);
return 0;
}
我得到 1 的输出!!和 4 在 gcc 中。我用的是 ubuntu linux
【问题讨论】:
-
好吧,当我使用
gcc -Wall编译时,我收到“警告:对'i' 的操作可能未定义”。您应该使用 -Wall 并注意警告。 -
有一个 C++ 常见问题解答问题:stackoverflow.com/questions/4176328/…
标签: c gcc operator-keyword associativity