What is the point of the logical operators in C?

后端 未结 5 1998
被撕碎了的回忆
被撕碎了的回忆 2020-12-18 07:49

I was just wondering if there is an XOR logical operator in C (something like && for AND but for XOR). I know I can split an XOR into ANDs, NOTs and ORs but a simple

5条回答
  •  天命终不由人
    2020-12-18 08:10

    You don't need logical XOR, I have forgotten the SO question, but it's similar to what you're thinking, basically we don't need XOR, it's equivalent to != anyway

    FALSE XOR FALSE == FALSE
    FALSE XOR TRUE == TRUE
    TRUE XOR FALSE == TRUE
    TRUE XOR TRUE == FALSE
    
    
    FALSE != FALSE == FALSE
    FALSE != TRUE == TRUE
    TRUE != FALSE == TRUE
    TRUE != TRUE == FALSE
    

    I'll search my favorites, and paste here the link later...

提交回复
热议问题