Or operator not working

后端 未结 8 1187
一向
一向 2020-12-12 07:44

When I enter start then the program outputs the else function even though I fulfilled the criteria, I have tried with && as well and it still didn\'t work. Any answe

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 08:10

    the Logical or operator, || only works in boolean expressions.

    For instance, if you had

    bool A = true
    bool B = false
    bool C = A||B;  
    

    than you will have set bool C to be True. IT just takes 2 booleans, and returns true if either of those booleans is true. That's all logical or does.

    You might want to try something like

    if (input.find("end") != std::string::npos || input.find("End") != std::string::npos)
    

提交回复
热议问题