From 3ecf1439928c98912f7e6cb3390363d1efdd7322 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:12:28 +0000 Subject: [PATCH] Initializacia --- cv7/program.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 0c69c32..8ebd22a 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -13,16 +13,13 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; memset(buffer, 0, SIZE); - - if (!fgets(buffer, SIZE, stdin) || buffer[0] == '\n') { + char* r = fgets(buffer, SIZE, stdin); + if (!r || buffer[0] == '\n') { return NULL; } - - buffer[strcspn(buffer, "\n")] = 0; - - struct tree* node = (struct tree*)calloc(1, sizeof(struct tree)); + buffer[strcspn(buffer, "\n")] = 0; + struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); - return node; }