Browse Source

check single letter

remotes/origin/Saba
Saba Fazlali 11 months ago
parent
commit
f10e07d76a
  1. 6
      src/main/c/Hangman/playHangman.c

6
src/main/c/Hangman/playHangman.c

@ -24,6 +24,12 @@ void playHangman(char *wordToGuess) {
continue; continue;
} }
// Check if the guess is a single letter
if (strlen(&guess) != 1) {
printf("Please enter only one letter.\n");
continue;
}
// Check if the letter has already been guessed by the player // Check if the letter has already been guessed by the player
if (strchr(guessedLetters, guess) != NULL) { if (strchr(guessedLetters, guess) != NULL) {
printf("You already guessed that letter. Try another letter.\n"); printf("You already guessed that letter. Try another letter.\n");

Loading…
Cancel
Save