Initializacia

This commit is contained in:
Kozar 2024-11-12 16:12:28 +00:00
parent 6ec70db799
commit 3ecf143992

View File

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