Browse Source

bug with new line in input fixed

remotes/origin/Saba
Saba Fazlali 11 months ago
parent
commit
4cdeaa2675
  1. 5
      src/main/c/Hangman/playHangman.c

5
src/main/c/Hangman/playHangman.c

@ -24,7 +24,10 @@ char getSingleCharInput() {
return '\0'; // Error or end of file 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 // Check if only one character is entered
if (strlen(input) == 2 && input[1] == '\n') { if (strlen(input) == 2 && input[1] == '\n') {

Loading…
Cancel
Save