Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cout << "Please enter a letter:" << endl;
- cin >> letter;
- letter = tolower(letter);
- while (wordLength > 0)
- {
- guessWord = guessWord + "_ ";
- wordLength--;
- }
- wordLength = word.length();
- while (numGuess < 6 && correct != wordLength)
- {
- hit = false;
- for (int i = 0; i < wordLength; i++)
- {
- if (word.at(i) == letter)
- {
- guessWord.at(i * 2) = letter;
- hit = true;
- correct++;
- }
- }
- if (hit == false)
- {
- cout << "Sorry this letter is not in this word." << endl;
- // hangimg = hangimg + hang[numGuess] + "\n";
- // cout << hangimg << endl;
- numGuess++;
- }
- cout << guessWord << endl;
- cout << endl << endl;
- if (correct == wordLength)
- {
- cout << "Congrats! You guessed right the words was " + word << endl;
- win = true;
- break;
- }
- cout << "Please enter a letter:" << endl;
- cin >> letter;
- }
- if (win == true)
- {
- cout << "You won!" << endl;
- }
- else
- {
- cout << "You lost... The word was " << word << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement