From 7dc3d6e0f94095f26fa0f86419c621263b9e2f68 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:11:20 +0100 Subject: [PATCH] Commit 5 code --- src/main/c/sudoku.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index dac8629..4329efc 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,6 +1,3 @@ - - - #include #include #include @@ -59,7 +56,21 @@ void availableLevelsFunction(int difficulty) { void selectLevel(int grid[SIZE][SIZE]) { int level = 0; printf("\nSelect a level:\n"); - + while (true){ + char level_select[10]; + scanf("%s", level_select); + + + level = level_select[0] - '0'; // Convert the first character to an integer + + if ((level >= 1 && level <= 3) && level_select[1] == '\0') { + printf("Input is correct"); + break; + } else { + printf("Invalid input. Please enter a number between 1 and 3.\n"); + + } + } }