How to compare string with const char*?

前端 未结 6 1917
一生所求
一生所求 2021-02-19 06:20
#include 
#include 
#include 
#include 
using namespace std;
int main()
{
        string cmd;
        whil         


        
6条回答
  •  旧巷少年郎
    2021-02-19 07:25

    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)
    

提交回复
热议问题