Hello to all,
I've lost touch with C programming for almost 3 years, so I forgot some subtle details.
I was solving one problem by writing C program and was surprised to learn that this code:
Code:
int main(void)
{
int x=3, y=2;
printf("%d", (x++));
printf("\n%d", (--y));
printf("\n%d", (++x));
printf("\n%d", (y--));
return 0;
}
is producing same result as this one:
Code:
int main(void)
{
int x=3, y=2;
printf("%d", x++);
printf("\n%d", --y);
printf("\n%d", ++x);
printf("\n%d", y--);
return 0;
}
How to explain this?
It seems that when execution of program comes to %d in printf function, it immediately substitutes this with a value similar like a = b++ no matter there are parenthesis.
Regards