Since operator priority ,
lower than =
one, this one ...
a=b+2,b*5;
... will actually be rated as ...
a = b + 2; b * 5;
C int i = b + 2, b * 5;
slightly different because the comma has different meanings in the declaration statements, separating the different declarations from each other. Consider this:
int a = 3, b = 4;
You still have a comma, but now it separates the two assignment variables when declaring. And the way the compiler tries to process this line from your example, but does not get any value from line b * 5
(this is not the purpose and declaration).
Now int a = (b + 2, b * 5)
is different: you assign the value of the expression b + 2, b * 5
variable a
type int
. The first subexpression is discarded, leaving you only with b * 5
.
source share