#include<stdio.h>
int main(){
int a=5;
printf("%d %d %d",a++,a++,++a);
return 0;
}
The answer is as follows:
In LINUX GCC compiler
7 6 8
In TURBO C
7 6 6
I can understand the answer of 7 6 6
, but I really can’t understand why the output of LINUX GCC compiler is 7 6 8
. Although I know this is undefiend behavior
, I still want to know why the results of 7 6 8
appear.
Original question source: Several classic interview questions in C language under Linux
http://blog.csdn.net/laojiu_/...
In fact, it is because this is undefined behavior that is not in the specification, so the compiler is correct no matter how it calculates it, and it is correct even if the results obtained by the compiler are not uniform.