C++ Error: Invalid conversion from ‘char’ to ‘const char*’

string compLetter = compWord[x];

compWord[x] gets char and you are trying to assign it to string, that’s wrong. However, your code should be something like

bool guessWord(string compWord)
{
    cout << "Guess a letter: ";
    char userLetter;
    cin >> userLetter;
    for (unsigned int x = 0; x < compWord.length(); x++)
    {
        char compLetter = compWord[x];
        if (compLetter == userLetter)
        {
            return true;
        }
    }
    return false;
}

Leave a Comment