0

How it works.. printf("number %d",b=(a++,a++)); printf("b=%d",b);

how the expression in 1st printf evaluated and how this all work ..with output

11th Jul 2018, 3:44 PM
Badal
Badal - avatar
2 Answers
+ 1
The tricky part of the snippet that you have provided is b=(a++, a++), Let me explain it by expanding upon the snippet itself. Consider the following version 1. int a = 1; 2. int b = 2; 3. 4. // b = (Expr1, Expr2) 5. b = (a++, a++); 6. printf("b is ℅d\n", b); 7. printf("a is %d", a); In line 4, what we are going to expect to being assigned to variable b is the Expr1 and the rest is discarded, that is, b = a++. Both Expr1 and Expr2 are evaluated before assignment, so, at the end of the day, the result of the two print statements would be as b is 2 a is 3
11th Jul 2018, 8:43 PM
To Seek Glory in Battle is Glorious
To Seek Glory in Battle is Glorious - avatar
0
Would you mind posting more of the code?
11th Jul 2018, 4:05 PM
John Romby
John Romby - avatar