I currently have a method called getResult which returns const char* now I am doing something like this
if(getResult=="Something")
{
...
}
However it seems this type of comparison doesn’t work. Isn’t “Something” also a const char pointer ? or in this case are the addresses being compared?
If
getResultis a method (member function) you need to call it to compare the result, so you probably want:If, on the other hand,
getResultis really a pointer to char (or pointer to const char), you need to convert one of the things you’re comparing tostringbefore the comparison):or:
IMO, this should almost never be necessary — instead of starting with a pointer to [const] char, then converting, you should normally use
std::stringthroughout.