Welcome to the Hangman Game! This is a simple command-line-based implementation of the classic word-guessing game. Players must guess a randomly selected word one letter at a time, with a limited number of tries.
- Random word selection from a predefined list.
- Case-insensitive guessing.
- Tracks and displays previously guessed letters.
- Input validation to prevent invalid guesses.
- Clear feedback for correct and incorrect guesses.
- Replay functionality to play multiple rounds without restarting the program.
- A random word is selected, and its letters are hidden (displayed as underscores
_
). - Players guess one letter at a time.
- Each correct guess reveals the letter(s) in the word.
- Incorrect guesses decrease the number of remaining tries.
- The game ends when:
- The player guesses the word correctly.
- The player runs out of tries.
- Players can choose to play again after each round.
- Ensure you have a C++ compiler (e.g., GCC, Clang, or MSVC) installed.
- Copy the game code into a file named
hangman.cpp
. - Open a terminal or command prompt and navigate to the file's directory.
- Compile the code using the following command:
g++ -o hangman hangman.cpp
- Run the compiled program:
./hangman
- Each player starts with 6 tries.
- Guess one letter at a time.
- Each incorrect guess reduces the remaining tries by one.
- Guesses are case-insensitive (
A
anda
are treated the same). - You win if you guess all letters in the word before running out of tries.
- You lose if your tries reach 0 before guessing the word.
This project is open-source and available for modification and distribution. Contributions are welcome!