A classic single-player console game built in C++. Guess the hidden word letter by letter before you run out of attempts!
Hangman is a word-guessing game. The program randomly selects a word from a built-in list — your goal is to reveal it by guessing one letter at a time. You have only 6 incorrect guesses before you lose.
Already tried a wrong letter? No penalty — the game reminds you and lets you try again.
- The program picks a random word from the word list
- Each turn, you guess one letter
- Correct guess — the letter is revealed in the word
- Wrong guess — you lose one of your 6 attempts
- Repeating a previously failed letter — no penalty, just a reminder
- Guess the full word before attempts run out to win
- C++11
- OOP:
Gameclass with encapsulated state <random>:std::mt19937+std::uniform_int_distributionfor fair random word selection<set>:std::setfor tracking already used wrong letters- Input validation:
std::cin.fail()handling with recovery viacin.clear()/cin.ignore()
g++ -std=c++11 Hangman-game.cpp -o Hangman-game
./Hangman-game- Open the project in Visual Studio
- Press
F5(Run)
Hangman-game/
└── Hangman-game.cpp # Full game logic
Welcome to the game Hangman!
Word - _ _ _ _ _ _ _ _ _ _ _
Enter letter: S
Word - _ _ _ _ _ _ S _ _ _ _
Enter letter: F
Fail! No letter found. You have only 5 to incorrectly put letter.
Word - _ _ _ _ _ _ S _ _ _ _
Enter letter: F
This letter was already tried and not in the word, try another!
...
You won, congrats!
The true word - I N T E R E S T I N G
- Draw the actual hangman ASCII art step by step
- Categories for words (animals, cities, tech terms)
- Difficulty levels (easy / medium / hard word length)
- Score tracking across multiple rounds
- Load words from an external file
Oleksandr Kopii
GitHub: @SamuraiSanch
⭐ If you enjoyed this project, feel free to leave a star!