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"); + + } + } }