Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. cout << "Please enter a letter:" << endl;
  2. cin >> letter;
  3. letter = tolower(letter);
  4.  
  5.  
  6. while (wordLength > 0)
  7. {
  8. guessWord = guessWord + "_ ";
  9. wordLength--;
  10.  
  11. }
  12.  
  13. wordLength = word.length();
  14.  
  15. while (numGuess < 6 && correct != wordLength)
  16. {
  17. hit = false;
  18. for (int i = 0; i < wordLength; i++)
  19. {
  20. if (word.at(i) == letter)
  21. {
  22. guessWord.at(i * 2) = letter;
  23. hit = true;
  24. correct++;
  25.  
  26. }
  27. }
  28. if (hit == false)
  29. {
  30. cout << "Sorry this letter is not in this word." << endl;
  31. // hangimg = hangimg + hang[numGuess] + "\n";
  32. // cout << hangimg << endl;
  33. numGuess++;
  34.  
  35. }
  36.  
  37. cout << guessWord << endl;
  38. cout << endl << endl;
  39.  
  40.  
  41. if (correct == wordLength)
  42. {
  43. cout << "Congrats! You guessed right the words was " + word << endl;
  44. win = true;
  45. break;
  46. }
  47. cout << "Please enter a letter:" << endl;
  48. cin >> letter;
  49.  
  50. }
  51.  
  52.  
  53. if (win == true)
  54. {
  55. cout << "You won!" << endl;
  56. }
  57. else
  58. {
  59. cout << "You lost... The word was " << word << endl;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement