I have an issue comparing a const char to a string… If I use Com_Printf (“%s”, value);
It returns what I want (0.3c), but how can I convert value to a string and compare that to 0.3c? This is what I have:
value = SearchInfostring(msg, "shortversion");
if (value != "0.3c")
{
Com_Printf (MSG_WARNING,
Com_Printf (MSG_WARNING,
"> WARNING: Value: Should be 0.3c, is: %s \n",
value);
//Run stuff
}
That returns:
WARNING: Value: Should be 0.3c, is: 0.3c
If value is of type const char*, expression
is comparing two pointers (addresses), not strings. You want to compare string and a string literal so can use
strcmp:Bear in mind that preferred string type in C++ is
std::string.