Problem with std::string::find()

后端 未结 2 753
盖世英雄少女心
盖世英雄少女心 2021-01-28 11:15

I\'m in trouble using std::string::find(). I read strings from console through the following code:

 50   while(command.find(exitString) != 0) {
 51         std::         


        
2条回答
  •  暖寄归人
    2021-01-28 12:10

    You are reading a line and then calling doSwitch() without checking if its exitString. In that case, when the input is exitString, else block at the end of doSwitch() function is executed, causing the program to print "Command Invalido" before exiting the loop.

    Is this what you observed?

    If its something else, please let us know for what input your code behaves incorrectly and what is the input and output.

提交回复
热议问题