Comma operator, comma operator c
Comma Operator
The comma operator ensures that the separated expressions are calculated in the order from left to right. In other words, the comma is an ordered point. All side effects produced by the left side of the comma take effect before the program runs to the right side of the comma.
This is especially important when the expression on the right of the comma uses the variable on the left of the comma:
Ounces ++, cost = ounces * FIRST_OZ
This will increase ounces and use the new value of ounces in the second subexpression.
Houseprice = 239,500; there is no syntax error. C treats it as a comma expression. houseprice = 239 makes the left subexpression, and 500 makes the right subexpression
For a comma expression, the value of the entire expression causes the value of the right expression
Example:
The running result is
This example illustrates the conclusion that the value of the entire comma expression is the value of the right expression.