From e6c0d1a3cb17fe338fa3531e98ae6f5933cff0ab Mon Sep 17 00:00:00 2001 From: Eric Chou Date: Tue, 11 Mar 2025 21:20:56 +0800 Subject: [PATCH] Reject letter input without row number This patch improves input validation by ensuring that a letter input must be followed by a row number. If the user enters only a letter within the valid board range without a corresponding row number, an error message is displayed. This enhances clarity and prevents invalid moves, ensuring correct input handling. Co-authored-by: charliechiou --- main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.c b/main.c index f40eb00..3b8e5bf 100644 --- a/main.c +++ b/main.c @@ -90,6 +90,9 @@ static int get_input(char player) x = y = 0; break; } + // input does not have row number + if (x > 0 && x <= BOARD_SIZE && parseX == 1) + printf("Invalid operation: No row number\n"); x -= 1; y -= 1; }