From a3c65d578682512b248572fb0b47bd36ca7eb97f Mon Sep 17 00:00:00 2001 From: Ivan Leichenko Date: Fri, 15 Nov 2024 06:23:33 +0100 Subject: [PATCH] cv7 --- cv7/program.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 7826b43..5171f62 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -88,20 +88,28 @@ void interact(struct tree *node) return; } - char answer; - while (scanf(" %c", &answer) == 1) + //while (scanf(" %c", &answer) == 1) + char answer[SIZE]; + while (fgets(answer, SIZE, stdin)) { - if (answer == 'a') + answer[strcspn(answer, "\n")] = 0; + + + if (answer[0] == '\0') + { + printf("Koniec vstupu\n"); + return; + } + + if (strcmp(answer, "a") == 0) { interact(node->left); return; - } - else if (answer == 'n') + } else if (strcmp(answer, "n") == 0) { interact(node->right); return; - } - else + } else { printf("Nerozumiem\n"); }