if(P2IN&BIT0 == BIT0 && P1IN& BIT2 == BIT2){·······}
这种情况 有错误,似乎只要满足P2IN&BIT0 == BIT0 就成立了
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
原因是C语言运算符优先级造成,
在上面的代码中用到了&,==,&& 种运算符,其中==的优先级最高,其次是&,再次是&&。你这样写代码不错才怪哦。
如果记不清楚优先级,最好的办法就是加上(),
很多公司的编程规范都要求写代码时要加()