I am trying to make a function that checks if a letter is in a word. I added the for-loop so that it can find all the letters. At the moment, it prints the same pos and doesn't increment.
Thanks in advance!
1 2 3 4 5 6 7 8 9 10 11 12 13
void checker(string word, char guess)
{
size_t pos;
for(int i=0; i < word.length(); i++)
{
pos=word.find(guess);
if(pos!=string::npos)
{
cout << "CORRECT! Found at " << pos << endl;
pos++;
}
}