Prob A Simple Fix To This Error Of A Program Looping

This is a function in a program of mine, inside of the function the program will loop once the user has entered their guess. I have fried my brain trying to figure this out. Most likely the simplest and easiest fix to it.






void HangMan(){
const int MAX_WRONG = 5;
vector<string> words;
words.push_back("COMPUTER");
words.push_back("SCIENCE");
words.push_back("ANATOMY");
words.push_back("ARBOR");
words.push_back("ENGLISH");
words.push_back("WIFI");
words.push_back("CRYPT");
words.push_back("FIXABLE");
words.push_back("DELUXE");
words.push_back("BUFFON");
words.push_back("BUFFALO");
words.push_back("AWKWARD");
words.push_back("CRUSH");
words.push_back("FIZZY");
words.push_back("DRINK");
words.push_back("DUI");
words.push_back("PARTNERS");
words.push_back("PLACENTA");
words.push_back("EMBRYO");
words.push_back("DINOSAUR");
words.push_back("GROCERIES");
words.push_back("POTATO");
words.push_back("TOMATO");
words.push_back("CHIPS");
words.push_back("FRIES");
words.push_back("COBWEB");
words.push_back("GOSSIP");
words.push_back("EXODUS");
words.push_back("IVY");
words.push_back("IVORY");
words.push_back("HYPHEN");
words.push_back("MATRIX");
words.push_back("ENCRYPTED");
words.push_back("HACKER");
words.push_back("TROJANHORSE");
words.push_back("VIRUS");
words.push_back("TEACHER");
words.push_back("INSTRUCTOR");
words.push_back("USA");
words.push_back("UK");
words.push_back("CHINA");
words.push_back("EUROPE");
words.push_back("GERMANY");
words.push_back("CHOCOLATE");
words.push_back("MARSHMALLOW");
words.push_back("BLACKJACK");
words.push_back("FRIENDS");
words.push_back("ENEMIES");
words.push_back("BAD");
words.push_back("GOOD");
srand(static_cast<unsigned int>(time(0)));
random_shuffle(words.begin(), words.end());
const string WORD_GUESS = words[0];
string soFar(WORD_GUESS.size(), '-');
string usedLetters = "";
int wrong = 0;

cout << "THIS IS HANGMAN!\2\n\n";
char guess;
cout << "\n\nEnter your guess: ";
cin >> guess;
guess = toupper(guess);
while ((wrong < MAX_WRONG) && (soFar != WORD_GUESS))
{
cout << "\n\nRemaining Guesses: " << (MAX_WRONG - wrong) << "\n";
cout << "\nYou have used this letter " << usedLetters << endl;
cout << "\nThe word so far looks like this: " << soFar << endl;
}
while (usedLetters.find(guess) != string::npos)
{
cout << "\nYou have already guess: " << guess << endl;
cout << "Enter your: ";
cin >> guess;
guess = toupper(guess);
}

usedLetters += guess;
if (WORD_GUESS.find(guess) != string::npos)
{
cout << guess << " is in the word\n";
for (int i = 0; i < WORD_GUESS.length(); i++)
{
if (WORD_GUESS[i] == guess)
{
soFar[i] = guess;
}
else
{
cout << guess << " is not in the word\n";
++wrong;
}
}
}
if (wrong == MAX_WRONG)
{
cout << "Game Over! You’ve Been Hanged\n";
}
else
{
cout << "The word was: " << WORD_GUESS << endl;
cout << "\n\n";
}
Sleep(5000);
main();
}
Your question is not clear at all!
inside of the function the program will loop once the user has entered their guess.
???!!!
line 107: As you were told in your previous thread, you CAN NOT call main(). Use a loop.

You have been asked multiple times to use code tags. PLEASE DO SO.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
If you're not going to make the slightest bit of effort to make your posts readable, why should we spend the slightest bit of effort helping you?
I will not respond further until you apply code tags.
Topic archived. No new replies allowed.