From f1b61336a5a5beb5d08874fb901e9657932f9b1e Mon Sep 17 00:00:00 2001 From: Ariana Ginju Date: Tue, 30 Jan 2024 12:01:52 +0000 Subject: [PATCH] Check whether the selected field is valid --- src/main/c/GameTic_Tac_Toe/game.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/GameTic_Tac_Toe/game.c b/src/main/c/GameTic_Tac_Toe/game.c index 48035ae..f0ddb37 100644 --- a/src/main/c/GameTic_Tac_Toe/game.c +++ b/src/main/c/GameTic_Tac_Toe/game.c @@ -56,3 +56,7 @@ void makeMove() { int row = (choice - 1) / 3; int col = (choice - 1) % 3; + // Überprüfe, ob das gewählte Feld gültig ist + if (choice >= 1 && choice <= 9 && board[row][col] != 'X' && board[row][col] != 'O') { + +