In the code below:
#include <stdio.h>
int main()
{
int a = 1;
int b = 1;
int c = a || --b;
int d = a-- && --b;
printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d);
return 0;
}
i was expecting the output to be:
a=0,b=1,c=1,d=0
because due to short circuiting in the line below, ie a-- returns 0 so the other part wont get executed right?
int d = a-- && --b;
The output is:
a = 0, b = 0, c = 1, d = 0
can anyone please explain?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…