Browse Source

score added

remotes/origin/Saba
Saba Fazlali 11 months ago
parent
commit
7981d1fb69
  1. 3
      src/main/c/Hangman/playHangman.c

3
src/main/c/Hangman/playHangman.c

@ -11,6 +11,7 @@ char toLower(char ch) {
void playHangman(char *wordToGuess) {
int mistakes = 0;
int score = 10;
char guessedLetters[30] = ""; //Guessed letters
char currentGuess[50]; //Current state of the guessed word
@ -62,12 +63,14 @@ void playHangman(char *wordToGuess) {
// Update mistakes (if the guess is wrong)
if (!found) {
mistakes++;
score--;
}
// Win: Check if the player guessed all the letters
if (strcmp(currentGuess, wordToGuess) == 0) {
currentState(currentGuess, mistakes);
printf("Bravo! You guessed the word: %s \n", wordToGuess);
printf("your score is %d/10\n", score);
printf("\n"
" __ __ __ __ _ \n"
" \\ \\ / /__ _ _ \\ \\ / /__ _ _ | |\n"

Loading…
Cancel
Save