diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 41f512f..2c82cfd 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -215,6 +215,21 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { void turnFunction(int grid[SIZE][SIZE]) { printf("\nTurn function - Choose an action:\n"); + + int action; + + while (true){ + char action_str[10]; + scanf("%s", action_str); + + action = action_str[0] - '0'; // Convert the first character to an integer + + if ((action >= 1 && action <= 6) && action_str[1] == '\0') { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 6.\n"); + } + } }