Using comma operator in c
I have read that comma operator is used to assign expression, and the
right expression is supplied to lvalue.
But why does this program assign left expression to lvalue when not using
parenthesis.I am using turbo c compiler
int b=2;
int a;
a=(b+2,b*5); // prints 10 as expected
a=b+2,b*5; // prints 4 when not using parenthesis
Also the following works
int a =(b+2,b*5);
And this generates error,I couldn't understand the reason.
int a =b+2,b*5; // Error
No comments:
Post a Comment