From dd1549d6f2a98ed140f3c9b1ca05186293414a73 Mon Sep 17 00:00:00 2001 From: fdai7037 Date: Wed, 8 Feb 2023 18:51:05 +0100 Subject: [PATCH] =?UTF-8?q?Abfangen=20von=20falschen=20Eingaben=20eingef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Paper-Bin.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Paper-Bin.c b/src/Paper-Bin.c index b666a81..10d7348 100644 --- a/src/Paper-Bin.c +++ b/src/Paper-Bin.c @@ -61,19 +61,26 @@ int main() void getStartPosition() { - while (ballX == -1) + while (Ballx == -1) { for (int i = 2, j = 0; i <= 20; i += 2, j++) { field[i][Bally] = j + '0'; } - } - Generatefield(); + Generatefield(); //printf("W\x84\hle die position des Balls (0-9):\n"); printf("W\x84\hle die position des Balls (0-9):\n"); scanf("%d", &Ballx); + if (Ballx < 0 || 9 < Ballx) + { + Ballx = -1; + continue; + } + Ballx = (Ballx + 1); + } + }