From 7dfcf1500b103523ef1027b87bca06e9fef3d055 Mon Sep 17 00:00:00 2001 From: ketrptr Date: Sun, 15 Dec 2024 14:04:26 +0100 Subject: [PATCH] fixed infinite loop on incalid input --- src/ui.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ui.c b/src/ui.c index f1797aa..21c4fb1 100644 --- a/src/ui.c +++ b/src/ui.c @@ -33,10 +33,13 @@ int main(void) { printf(" -5- Faecher Importieren\n"); printf(" -6- Planer beenden\n"); printf(" Wähle die gewünschte Option aus\n"); - if (scanf("%d", &choice) != 1) { + volatile int r = scanf("%d", &choice); + if (r != 1) { printf("Falsche Eingabe\n"); + fgetc(stdin); + choice = 0; + continue; }; - // choice = 0; switch (choice) { case 1: @@ -95,6 +98,7 @@ int main(void) { case 3: if (listT == NULL) { printf("Die Liste ist leer"); + break; } else { llistPrintT(listT); // llist *iterator = list;