Explaination of behavior in C
Given the code
Code:
int i = 1;
int a[4] = {0, 10, 20, 30};
a[i++] = i++; // a[i] = i; i = i + 1; i = i + 1;
printf(“%d %d %d %d %d\n”,a[0],a[1],a[2],a[3],i);
The output is in C: 0 1 20 30 3
However, the output in Java and C# is (with printf statment replace in Java and C#): 0 2 20 30 3
Just curious as to how C evaluates this vs. Java and C#.
(Order of evaluation vs. precedence)
I never really thought about this until now. I really assumed all these languages that evaluate expression in the same way.
Any thoughts?
Mr. C. :)