diff options
author | Robby Zambito <contact@robbyzambito.me> | 2021-07-26 22:13:40 -0400 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2021-07-26 22:13:40 -0400 |
commit | 959da8c2d1cb33b0f7046d3d5d4d80c586cfbcf4 (patch) | |
tree | 8654e7dd4ffeb6e1b8dfc0b6f2aa21c8b5c0dc9d | |
parent | 2f5ede7841826397b872c79ee2624c07e45f60ea (diff) |
Removing trailing newline from input
-rw-r--r-- | src/game_loop.c | 9 |
1 files 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); |