问题
Can any one explain why c still equal 15 after execution
int main(void)
{
int t,a=5,b=10,c=15;
t= ++a||++c;
printf("%d %d %d",t,a,c);
}
回答1:
The logical-or operator ||
is a short-circuit operator. If the left side evaluates to a true boolean value (i.e. not 0), then the right side doesn't execute.
Similarly for the logical-and operator &&
, if the left hand side is false (i.e. 0) the right hand side does not execute.
来源:https://stackoverflow.com/questions/31415375/logical-operation-pre-increment-in-c