If I have a char*
that is the output of another function, and I know it is one of the 10 known words, what is the best way to find what is it?
converting the char*
to string
bystd::string(char*)
, then using string.compare()
?
char* c = "hi";
string s = std::string(c);
if (s.compare("hello") )
Is this the best way? I can not directly write:
char* c ="hi";
if(c == "hello")