From 31cd3999f233425c88b963d1d930e5aecae13561 Mon Sep 17 00:00:00 2001 From: Ivan Leichenko Date: Fri, 15 Nov 2024 07:11:55 +0100 Subject: [PATCH] cv7 --- cv7/program.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 8b95c56..e779976 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -15,7 +15,7 @@ struct tree struct tree* read_tree() { char buffer[SIZE]; - if (!fgets(buffer, SIZE, stdin) || buffer[0] == '\n') + if (!fgets(buffer, SIZE, stdin) || buffer[0] == '\n' || buffer[0] == '\0') { return NULL; } @@ -136,6 +136,11 @@ void interact(struct tree *node, int fstenter) int main() { struct tree *root = read_tree(); + if(root == NULL) + { + printf("Chybna databaza\n"); + return 0; + } //getchar(); int leafs = count_leaf_nodes(root); if(leafs == 0)