diff --git a/src/main/c/Hangman/playHangman.c b/src/main/c/Hangman/playHangman.c index 78298f9..19ab800 100644 --- a/src/main/c/Hangman/playHangman.c +++ b/src/main/c/Hangman/playHangman.c @@ -1,5 +1,14 @@ #include "playHangman.h" +// Converts the letter to lower case +char toLower(char ch) { + // Convert uppercase letter to lowercase manually + if (ch >= 'A' && ch <= 'Z') { + return ch + ('a' - 'A'); + } + return ch; +} + void playHangman(char *wordToGuess) { int mistakes = 0; @@ -19,11 +28,14 @@ void playHangman(char *wordToGuess) { scanf(" %c", &guess); // Check if the guess is lower case and is a letter (valid) - if (!isalpha(guess) || isupper(guess)) { - printf("Please enter a valid lowercase alphabet.\n"); + if (!isalpha(guess)) { + printf("Please enter a valid alphabet.\n"); continue; } + // Convert uppercase letter to lowercase + guess = toLower(guess); + // Check if the guess is a single letter if (strlen(&guess) != 1) { printf("Please enter only one letter.\n");