Or operator not working

后端 未结 8 1211
一向
一向 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:09

    Replace

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

    with:

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

    Similarly for your other if.

    It seems obvious what your expression means, but when you break it down it really doesn't make sense. find expects a string, and "end" || "End" is not a string.

提交回复
热议问题