Hangman Game: Help with finding error

Hi. I'm trying to finish my program on hangman but I jsut can't seem to find the last mistake. The only proglem with the code is that when I enter a letter that exists in the word, it appears to fill that letter with every blank. Lets say the word is "CHICKEN". If I enter the letter "c" (which touppers to "C") it will output "CCCCCCC". And If I enter "n", it will change all the letters to "NNNNNNN."
Help would be much appreciated.

#include <iostream> //input, output
#include <string>
#include <vector>
#include <algorithm> //find
#include <cctype> //toupper
#include <ctime> //radomization

using namespace std;




int main() {
const int Max_Wrong = 6;

vector<string>words;

words.push_back("PIZZA"); //words used
words.push_back("COUPON");
words.push_back("NOODLES");
words.push_back("RADDISH");
words.push_back("CHICKEN");
words.push_back("COLA");


srand(static_cast<unsigned int>(time(0))); //randomize words

random_shuffle(words.begin(), words.end()); //shuffles words in range

const string the_Word = words[0]; //string calls the words that going to be picked

int wrong = 0;

string so_Far(the_Word.size(), '_'); // letters, blanks
string used; // letters used

cout << "Welcome to Hangman" << endl;


while ((wrong < Max_Wrong) && (so_Far != the_Word))
{

cout << "You have " << (Max_Wrong - wrong);
cout << " chances left.\n";
cout << "You have used the letters:\n" << used << endl;
cout << "So far, the word is:\n\n " << so_Far << endl;

char guess; //letter guess

cout << "Enter a letter:";
cin >> guess; //input letter
guess = toupper(guess); //lower to upper

//check if letter already entered
while (used.find(guess) != string::npos) //npos string lib
{
cout << "You have already entered " << guess << endl;
cout << "Enter a letter:";
cin >> guess;
guess = toupper(guess); //lower to upper
}

used += guess; //records letter and after

if (the_Word.find(guess) != string::npos) { //checks if guess is in called string

cout << guess << " IS in the word,\n";

for (int i = 0; i < the_Word.length(); ++i) //loops throught the word
{
if (the_Word[i == guess]) //check if guess is in word
{
so_Far[i] = guess;
}
}
}

else
{
cout << guess << " IS NOT in the word.\n";
++wrong;
}


if (wrong == 0) //graphics
{
cout << " __\n";
cout << " | | \n";
cout << " | \n";
cout << " | \n";
cout << " | \n";
cout << " | \n";
cout << " _|__ \n" << endl;
}
else
{
cout << endl;
}
if (wrong == 1)
{
cout << " __\n";
cout << " | | \n";
cout << " | o \n";
cout << " | \n";
cout << " | \n";
cout << " | \n";
cout << " _|__ \n" << endl;
}
else
{
cout << endl;
}
if (wrong == 2)
{
cout << " __\n";
cout << " | | \n";
cout << " | o \n";
cout << " | / \n";
cout << " | \n";
cout << " | \n";
cout << " _|__ \n" << endl;
}
else
{
cout << endl;
}
if (wrong == 3)
{
cout << " __\n";
cout << " | | \n";
cout << " | o \n";
cout << " | /@ \n";
cout << " | \n";
cout << " | \n";
cout << " _|__ \n" << endl;
}
else
{
cout << endl;
}
if (wrong == 4)
{
cout << " __\n";
cout << " | | \n";
cout << " | o \n";
cout << " | /@| \n";
cout << " | \n";
cout << " | \n";
cout << " _|__ \n" << endl;
}
else
{
cout << endl;
}
if (wrong == 5)
{
cout << " __\n";
cout << " | | \n";
cout << " | o \n";
cout << " | /@| \n";
cout << " | / \n";
cout << " | \n";
cout << " _|__ \n" << endl;
}
else
{
cout << endl;
}
}//close while

if (wrong == Max_Wrong)
{
cout << "Game over. \n";
cout << " __\n";
cout << " | | \n";
cout << " | o \n";
cout << " | /@| \n";
cout << " | / \ \n";
cout << " | \n";
cout << " _|__ \n";
cout << "You lost" << endl;
}
else
{
cout << "Correct. You win! " << endl;
}

cout << "The word is " << the_Word << endl;

system("pause");
}
The problem here lies in line 71.
if (the_Word[i == guess]) //check if guess is in word

As you can see. You messed up on the brackets basically.
Thank you so much. I really appreciat it !!! :)
Topic archived. No new replies allowed.