#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string cmd;
while(strcmp(cmd.c_str(),"exit")==0 && strcmp(cmd.c_str(),"\exit")==0)
{
cin>>cmd;
cout<<cmd;
}
return 0;
}
I am stuck.
After fixing a couple of small bugs, this works on my machine:
However, I wonder why you want to use
std::strcmp()at all. As you have just found out, it’s not as easy to use as thestd::stringclass. Thisworks just as well, is easier to understand, and thus easier to get right.