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

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

关于C语言的优先级的问题

#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
能不能详细说一说这个计算顺序


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...