From c0b7fbdd0ab134f465e8ba6bdcfaa55825e8b2e6 Mon Sep 17 00:00:00 2001 From: Deinerovych Date: Wed, 6 Nov 2024 10:16:26 +0100 Subject: [PATCH] 9 --- cv7/program.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index d985f0b..d101106 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -57,13 +57,16 @@ void run_expert_system(Node *node) { printf("%s\n", node->text); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost: "); char answer; - scanf(" %c", &answer); + if (scanf(" %c", &answer) != 1) { + printf("Koniec\n"); + return; + } if (answer == 'a') { node = node->yes; } else if (answer == 'n') { node = node->no; } else { - printf("Neplatná odpoveď. Koniec.\n"); + printf("Koniec\n"); return; } }