My question is regarding assigning a variable to it's post-incremented value. This was undefined in previous versions of C as pointed out in this question but it's defined in C17.
I've followed this StackOverflow post regarding post-incrementing variables in C. So, if we have the following code snippet -
int a = 1;
int b = a++;
printf("%d\n", b);
The variable b
gets assigned the initial value of a
(i.e. 1) before a
gets incremented. Hence, the output is 1, as expected.
But, what if we assign a
to it's post-incremented value?
int a = 1;
a = a++;
printf("%d\n", a);
Similar to the above case, a
first gets assigned the original value (1), but shouldn't the incremented value get printed as the final output?