diff --git a/cv7/program.c b/cv7/program.c index 5d62b4c..ab48413 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -38,7 +38,6 @@ Node* parse_rules() { int stack_top = -1; while (fgets(line, sizeof(line), stdin)) { - // Trim newline line[strcspn(line, "\n")] = 0; if (strlen(line) == 0) break; @@ -72,19 +71,17 @@ Node* parse_rules() { void ask_question(Node *node) { if (!node) return; if (node->yes == NULL && node->no == NULL) { + printf("*%s\n", node->content); printf("Koniec\n"); return; } printf("%s\n", node->content); - if (node->yes && node->yes->content[0] != '*') { - printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); - } char response; while (1) { response = getchar(); - getchar(); // To capture newline + getchar(); // Capture newline if (response == 'a' && node->yes) { ask_question(node->yes); break; @@ -109,9 +106,9 @@ int main() { int answer_count = count_answers(root); printf("Pozna %d druhov ovocia a zeleniny.\n", answer_count); + printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); if (root) { - printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); ask_question(root); }