User`s manual

244 digi.com Operators
Comma operator. This operator, unique to the C language, is a convenience. It takes two operands: the left
operand—typically an expression—is evaluated, producing some effect, and then discarded. The right-
hand expression is then evaluated and becomes the result of the operation.
This example shows somewhat complex initialization and stepping in a for statement.
for( i=0,j=strlen(s)-1; i<j; i++,j—){
...
}
Because of the comma operator, the initialization has two parts: (1) set i to 0 and (2) get the length of
string s. The stepping expression also has two parts: increment i and decrement j.
The comma operator exists to allow multiple expressions in loop or if conditions.
The table below shows the operator precedence, from highest to lowest. All operators grouped together
have equal precedence.
,
Table 13-1. Operator Precedence
Operators Associativity Function
() [] -> . left to right member
! ~ ++ --
(type) * & sizeof
right to left unary
* / % left to right multiplicative
+ - left to right additive
<< >> left to right bitwise
< <= > >= left to right relational
== != left to right equality
& left to right bitwise
^ left to right bitwise
| left to right bitwise
&& left to right logical
|| left to right logical
? : right to left conditional
= *= /= %= += -=
<<= >>= &= ^= |=
right to left assignment
, (comma) left to right series