How to compare string with const char*?

前端 未结 6 1151
灰色年华
灰色年华 2021-02-19 06:51
#include 
#include 
#include 
#include 
using namespace std;
int main()
{
        string cmd;
        whil         


        
6条回答
  •  被撕碎了的回忆
    2021-02-19 07:10

    Your problem are the while conditions.

    You probably would want do exit the loop when the user enters exit, so you should use:

    while(strcmp(cmd.c_str(),"exit")!=0 && strcmp(cmd.c_str(),"\exit")!=0)
    

提交回复
热议问题