diff --git a/cv8/program.c b/cv8/program.c index e922217..f161177 100644 --- a/cv8/program.c +++ b/cv8/program.c @@ -18,8 +18,8 @@ struct tree* read_tree(){ buffer[x-1]='\0'; assert(r); + if(buffer[0] != '\0'){ - struct tree* node = calloc(1,sizeof(struct tree)); memcpy(node->value, buffer,50); if(buffer[0] != '*'){ @@ -29,11 +29,12 @@ struct tree* read_tree(){ if(node->right == NULL){ node->right = read_tree(); } - } + } + //if(node->left != NULL && node->right != NULL){ return node; } - // } + } struct tree* search(struct tree* this){ @@ -43,7 +44,7 @@ struct tree* search(struct tree* this){ int x = strlen(buffer); buffer[x-1]='\0'; memcpy(buffer, this->value, 50); */ - if(this != NULL){ + if(this->left != NULL && this->right != NULL){ if(c == 'a'){ printf("%s\n", this->value); this->left = search(this->left);