From f10e07d76a2d08bb9dc7cf31b8df837203f4cbd1 Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Fri, 2 Feb 2024 16:51:38 +0100 Subject: [PATCH] check single letter --- src/main/c/Hangman/playHangman.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/c/Hangman/playHangman.c b/src/main/c/Hangman/playHangman.c index 6930fdd..78298f9 100644 --- a/src/main/c/Hangman/playHangman.c +++ b/src/main/c/Hangman/playHangman.c @@ -24,6 +24,12 @@ void playHangman(char *wordToGuess) { 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 if (strchr(guessedLetters, guess) != NULL) { printf("You already guessed that letter. Try another letter.\n");