< Previous | Contents | Next >

Entering the Main Loop

Next I enter the main loop, which continues until the player has made too many incorrect guesses or has guessed the word.

//main loop

while ((wrong < MAX_WRONG) && (soFar != THE_WORD))

{

144 Chapter 4 n The Standard Template Library: Hangman


cout << "\n\nYou have " << (MAX_WRONG - wrong); cout << " incorrect guesses left.\n";

cout << "\nYou’ve used the following letters:\n" << used << endl; cout << "\nSo far, the word is:\n" << soFar << endl;