This commit is contained in:
Maryna Kravtsova 2020-11-22 17:56:24 +01:00
parent 6e2878794f
commit c4c808544f

View File

@ -17,7 +17,10 @@ struct tree* read_tree(){
int x = strlen(buffer); int x = strlen(buffer);
buffer[x-1]='\0'; buffer[x-1]='\0';
assert(r); if(r == NULL){
printf("Chybna databaza\n");
exit(0);
}
if(buffer[0] != '\0'){ if(buffer[0] != '\0'){
struct tree* node = calloc(1,sizeof(struct tree)); struct tree* node = calloc(1,sizeof(struct tree));
@ -132,12 +135,14 @@ int count_all(struct tree* node){
int main(){ int main(){
printf("Expert z bufetu to vie.\n");
struct tree* tree = NULL; struct tree* tree = NULL;
tree = read_tree(); tree = read_tree();
int count = count_leaves(tree); int count = count_leaves(tree);
printf("Expert z bufetu to vie.\n");
printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Pozna %d druhov ovocia a zeleniny.\n", count);
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");