main(){
int a = 5;
int b = 6;
printf("%d %d %d",a==b,a=b,a<b);
}
Output in my testing
1 6 1
In above program I am expecting output as 0 6 0 . In some compilers it is giving this output (e.g. Xcode) but where as in some other compilers it is giving output as 1 6 1 . I couldn't find the explanation . It is also the case of Sequence point.
Consider this below program
main(){
int a = 5;
int b = 6;
printf("%d %d %d",a<b,a>b,a=b);
printf("%d %d",a<=b,a!=b);
}
Output in my testing
0 0 6 1 0
this below program is giving the correct output which i am expecting which is 0 0 6 1 0
but why the above program is not giving the output as 060 in most of the compilers
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…