The comma operator in C is a sequence point which means that the expressions separated by the comma are executed from left to right. The value of the whole expression is the value of the rightmost expression, in your case 2.1
, which gets assigned to the variable p
.
Since the expressions in your example don’t have side effects, the use of the comma separator here makes no sense whatsoever.
The parentheses on the other hand are important since the assignment operator (=
) binds stronger than the comma operator (it has higher precedence) and would get evaluated before the comma operator without the parentheses. The result would thus be p == 1
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…