From b7e46be38d161ae37609c6fbf4b65d6e138182d4 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 18:05:10 +0000 Subject: [PATCH] Initializacia --- cv7/program.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index c056c10..e14a3aa 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -51,12 +51,14 @@ void run_tree(struct tree* tree) { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); char response; - if (scanf(" %c", &response) != 1) { - printf("Koniec vstupu\n"); - return; - } else if (response != 'a' && response != 'n') { - printf("Nerozumiem\n"); - return; + while (1) { + // Wait for user input + if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { + printf("Nerozumiem\n"); + // Re-prompt for input + continue; + } + break; // Valid input received } if (response == 'a') {