Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

#include <stdio.h>
void main()
{
int a=1,b=2,c=3;
a++||b++&&c++;
printf("%d %d %d",a,b,c);
}

请问一下++的优先级不是最高的吗,那么a,b,c不都应该都自加了吗
为什么a,b,c的值还是分别为2,2,3
能不能详细说一说这个计算顺序


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

问得挺好的,根本原因在于你混淆了"优先级"和"表达式求值顺序"两个概念,具体可以参考这里:
https://stackoverflow.com/que...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...