Skip to content

itsW0LFIX/Digit_Hunt

Repository files navigation

Random numbers guessing game

the code appears to be a guessing game implemented in C. Players guess a sequence of random numbers, and the game evaluates their guesses based on whether the numbers are in the correct positions or not. Additionally, the code includes features such as a scoring system, an option to save scores, and a top score display.

Here are some key points about your code:

Game Initialization:

  • The game starts with a main menu where the user can choose to start, view top scores, or exit.

Difficulty Selection:

  • The user selects the difficulty level, indicating the number of digits in the random number to guess.

Attempts and Scoring:

  • The user specifies the maximum number of attempts allowed.
  • Scoring is calculated based on the number of attempts and other factors.

Guessing Logic:

  • The game generates a random number with the specified number of digits.
  • The user makes guesses, and the program provides feedback based on whether the guessed numbers are in the correct location or not.

Top Score Display:

  • The user can view top scores, which are read from a file and displayed in descending order.

Saving Scores:

  • After winning, the user has the option to save their name and score to a file.

Replay Option:

  • The user can choose to play the game again or exit.

File Handling:

  • File operations are used to read and write top scores to a file.

It's worth noting that the code includes some improvements, such as sorting top scores and displaying only the top 10 scores. Additionally, it handles file operations more gracefully.

Note

The code assumes a maximum of 7 digits in the random sequence, and some parts, like the scoring system and file handling, may need adjustment based on the specific requirements of your game. Additionally, ensure that you have proper error handling, especially when dealing with file operations.

About

Terminal-based C game to guess multi-digit random numbers with scoring and leaderboard.

Topics

Resources

Stars

Watchers

Forks

Languages