diff --git a/du6/program.c b/du6/program.c index b295179..879f989 100644 --- a/du6/program.c +++ b/du6/program.c @@ -30,10 +30,7 @@ struct tree* read_tree(){ if(!r) { return NULL; } - buffer[strcspn(r, "\n")] = '\0'; - if(buffer[0] == '\0'){ - return NULL; - } + buffer[strcspn(buffer, "\n")] = '\0'; struct tree* node = calloc(1,sizeof(struct tree)); memcpy(node->value,buffer,SIZE); if(buffer[0] == '*'){ @@ -76,17 +73,15 @@ int main(void){ struct tree* tree = read_tree(); char line[SIZE]; - - while( fgets(line, sizeof(line), stdin)){ - if(strcmp(line, "\n") == 0){ - whitespace = true; - break; - } - - } int numOfLeaves = count_leaves(tree); char answer[SIZE]; - bool exs = false; + while (fgets(line, sizeof(line), stdin)) { + line[strcspn(line, "\n")] = '\0'; + if (line[0] == '\0') { + whitespace = true; + break; + } +} printf("Expert z bufetu to vie.\n"); if(!tree || !whitespace){ printf("Chybna databaza\n");