This project is a simple implementation of the classic Hangman game written in C. The game challenges players to guess a hidden word one letter at a time. Players must guess correctly within a limited number of attempts to win the game.
- Word guessing functionality with customizable word lists.
- Display of partially guessed words and incorrect guesses.
- Adjustable difficulty through maximum attempts.
- Interactive text-based interface.
- The game selects a random word from a predefined list.
- The player is shown the word as a series of underscores (e.g.,
____for a four-letter word). - The player guesses one letter at a time by entering a character.
- Correct guesses reveal the positions of the guessed letter in the word.
- Incorrect guesses are tracked, and the player loses an attempt for each incorrect guess.
- The game ends when the player either:
- Guesses the entire word (Win).
- Runs out of attempts (Lose).
- Clone or download this repository.
- Open the project folder in your preferred IDE or terminal.
- Compile the source code using a C compiler. For example, with GCC:
gcc hangman.c -o hangman
- Run the compiled program:
./hangman
hangman.c: The main source file containing the game logic.words.txt(optional): A text file containing a list of words for the game, one word per line.
- Adding Words:
- Update the word list in the code or provide a
words.txtfile.
- Update the word list in the code or provide a
- Changing Difficulty:
- Modify the maximum number of attempts in the code.
This project requires a standard C compiler and the standard C library. No additional dependencies are needed.
- Words must not contain special characters or spaces.
- Case sensitivity: All words and guesses are treated as lowercase. Ensure the word list is in lowercase.
- Add support for dynamic word lists from external files.
- Implement a graphical version of the game.
- Add multiplayer support.
This project is open-source and available under the MIT License.
Thanks to classic games like Hangman for inspiring this project!