From 959da8c2d1cb33b0f7046d3d5d4d80c586cfbcf4 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Mon, 26 Jul 2021 22:13:40 -0400 Subject: Removing trailing newline from input --- src/game_loop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/game_loop.c b/src/game_loop.c index f71d204..5f893e0 100644 --- a/src/game_loop.c +++ b/src/game_loop.c @@ -64,11 +64,14 @@ static struct move get_move(enum player_color board[8][8], } } - if (STREQ(input, "h\n")) { + // Remove trailing newline + input[strcspn(input, "\n")] = '\0'; + + if (STREQ(input, "h")) { print_help(); - } else if (STREQ(input, "p\n")) { + } else if (STREQ(input, "p")) { print_board(board); - } else if (STREQ(input, "g\n")) { + } else if (STREQ(input, "g")) { puts("NOT IMPLEMENTED YET!"); } else { sscanf(input, "%d %d", &move.row, &move.col); -- cgit v1.2.3