【发布时间】:2013-08-02 07:34:31
【问题描述】:
下面是我的 C 代码 sn-p。
void main(){
int x = 7;
x = x++;
printf("%d",x);
}
输出:8
public static void main(String[] args){
int x = 7;
x = x++;
System.out.println(x);
}
输出:7
我不明白为什么两种语言都给出不同的输出。 我在下面提到了链接 What is x after "x = x++"?
【问题讨论】:
-
第一个代码 sn-p 在 C 中是 Undefined Behaviour。
-
和这个著名的完全一样的帖子!!! [此处链接][1] [1]:stackoverflow.com/questions/7911776/what-is-x-after-x-x?lq=1
-
它在哪里说他们应该表现得一样?
标签: java c post-increment