Syntax
The comma operator separates expressions (which have value) in a way analogous to how the semicolon terminates statements, and sequences of expressions are enclosed in parenthesis analogously to how sequences of statements are enclosed in braces: (a, b, c)
is a sequence of expressions, separated by commas, which evaluates to the last expression c
while {a; b; c;}
is a sequence of statements, and does not evaluate to any value. Note that a comma can only occur between two expressions – commas separate expressions – unlike the semicolon, occurs at the end of a (non-block) statement – semicolons terminate statements.
The comma operator has the lowest precedence of any C operator, and acts as a sequence point. In a combination of commas and semicolons, semicolons have lower precedence than commas, as semicolons separate statements but commas occur within statements, which accords with their use as ordinary punctuation: a, b; c, d
is grouped as (a, b); (c, d)
because these are two separate statements.
Read more about this topic: Comma Operator