diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index d3b3c29..8f3e976 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -80,11 +80,10 @@ char* getUserInput(){ printf( ":" ); fgets(userInput, sizeof(userInput), stdin); - size_t len = strlen(userInput); - if (len > 0 && userInput[len - 1] == '\n') { - userInput[len - 1] = '\0'; + size_t lengthOfInput = strlen(userInput); + if (lengthOfInput > 0 && userInput[lengthOfInput - 1] == '\n') { + userInput[lengthOfInput - 1] = '\0'; // declare end of command } - return userInput; }