I've gone through other similar questions, but trying to understand the situation I'm facing.
So, here's my two line C code.
int i=0;
printf("%d %d %d %d %d",i++,i--,++i,--i,i);
And here are the outputs I get from GCC and Turbo C Compiler.
GCC
Output:
-1 0 0 0 0
Turbo C
Output:
-1 0 0 -1 0
I tried all sorts of experiments with pre-increment operator individually, and both compilers work similar but when I use above printf
statement, output differs.
I know that Turbo C is age-old compiler and now obsolete and non-standard but still can't get an idea what's wrong with above code.