I have this portion of a code and I'm receiving this error error C2664: 'strcmp' : cannot convert parameter 1 from 'std::string' to 'const char *'
So how would I convert std::string to const char * ??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
bool inDictionary(string word, string dictionary[198])
{
int index = 0;
bool in_boolean = false;
while (index < 198 && in_boolean == true)
{
in_boolean = strcmp(word, dictionary[index]);
index++;
}
return in_boolean;
}
This is what I have but it still produces the same error when i debug
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
bool inDictionary(string word, string dictionary[198])
{
int index = 0;
bool in = false;
in = word == dictionary[index];
while (index < 198 && in == true)
{
in = strcmp(word, dictionary[index]);
index++;
}
return in;
}