c语言运算问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 15:38:24
int b=5,d;
d=(++b)+++b与d=(++b)+(++b)区别

能详细说明下 谢谢

d=(++b)+++b相当于d=((++b)++)+b ++是自右向左结合的,而++在变量后面的,是先算出变量所在表达式的值再自加的,在变量前面的正好相反
d=(++b)+(++b)就是2个++号都在变量前面,先运算自加

These types of expressions are very ambiguous and unsafe. Their values sometimes are compiler dependent. We should avoid them completely. However, they are good for theoretical research.

it is up to the compiler!