From 6f35efdf81ebcfcc7ddaca03e90212d9e1a3b59d Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:15:12 +0100 Subject: [PATCH] Commit 15 code --- src/main/c/sudoku.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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"); + } + } }