编程知识 cdmana.com

Solve, why is y still 3?

solve , Why? y The value of the or 3?

#include<stdio.h>int main(){    int x = 2, y = 3, a;    a = (!x-- && --y) ? 2 : 3;    printf("x=%d,y=%d,a=%d", x, y, a);    return 0;}

img




Refer to the answer 1:

(!x-- && --y), Here because !x = 0 ,0 && --y Short circuit effect ,--y It's not going to work .




Refer to the answer 2:



Refer to the answer 3:

! High priority ,!x=0 了




Refer to the answer 4:

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/11/20211127125039560v.html

Tags solve
Scroll to Top