From 4cdeaa26753bda87dc3f3f4e06db39708aecdae4 Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Fri, 2 Feb 2024 18:00:46 +0100 Subject: [PATCH] bug with new line in input fixed --- src/main/c/Hangman/playHangman.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/c/Hangman/playHangman.c b/src/main/c/Hangman/playHangman.c index ed0e32c..ec36659 100644 --- a/src/main/c/Hangman/playHangman.c +++ b/src/main/c/Hangman/playHangman.c @@ -24,7 +24,10 @@ char getSingleCharInput() { return '\0'; // Error or end of file } - ignoreExtraInput(); // Ignore extra characters + // Check if the last character is a newline, if not, consume the rest of the line + if (input[strlen(input) - 1] != '\n') { + ignoreExtraInput(); + } // Check if only one character is entered if (strlen(input) == 2 && input[1] == '\n') {