How would I find a partial word match/find c++
<p>I'm having trouble with a scrabble-like game I'm making. My goal was to have 5 random letters that possibly match at least one word in a dictionary I made so the game can start. I've done this but since the 5 letters are random there's probably a slim chance it will match one of the words in the dictionary. I've done test runs and got random letters but no match every time (it works hardcoded however). I figure if I can find a partial match, I can keep the letter(s) that do form part of a word and get different letters for the ones that don't. The thing is, I don't know how to go about doing this. </p>

<p>This is my code for the five random letters:</p>

<pre><code>void fiveLetters()
{
    srand(time(NULL));

    for (int i =0; i&lt;=4; i++) // display 5 random letters
    {
        int n = rand()%26;
        char letter = (char)(n+97);
        letters[i] = letter;
        cout &lt;&lt; letters[i]&lt;&lt; " ";
    }
    letters[5] = '\0'; // last value in char array null value so I can convert to string
    attempt = letters; // the 4 letters

    checkWords();
}
</code></pre>

<p>For checking if it matches a word I use:</p>

<pre><code>void checkWords()
{
    if (find(words.begin(),words.end(), attempt) != words.end()) // if matches word in set
    {
        cout &lt;&lt; " Words found" &lt;&lt; endl;
    }
    else // if it doesn't match
    {
        cout &lt;&lt; "cannot find word " &lt;&lt; endl;
        attempt.clear();
        fiveLetters();
    }
}
</code></pre>

<p>The dictionary is a text file with a lot of words however since I'm just trying to get things working before I implement it, I used 5-10 words and put them in a <code>set&lt;string&gt;</code>. Sorry for the long read, any help is appreciated!</p>