diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 8f5f0b0..5b76aca 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -260,6 +260,22 @@ void turnFunction(int grid[SIZE][SIZE]) { void tipFunction(int grid[SIZE][SIZE]) { printf("\nTip function - Choose an option:\n"); + + int option = 0; + + while (true){ + char tip_str[10]; + scanf("%s", tip_str); + + + option = tip_str[0] - '0'; // Convert the first character to an integer + + if ((option >= 1 && option <= 3) && tip_str[1] == '\0') { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 3.\n"); + } + } }