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; }