How to compare strings
You need to use strcmp
.
if (strcmp(string,"add") == 0){
print("success!");
}
In C++ the std::string
class implements the comparison operators, so you can perform the comparison using ==
just as you would expect:
if (string == "add") { ... }
When used properly, operator overloading is an excellent C++ feature.