This commit is contained in:
Bohdan Kapliuk 2024-11-14 14:37:42 +02:00
parent 4a23ba9b26
commit b640c1eb0e

View File

@ -15,12 +15,10 @@ struct tree* read_tree(int* counter) {
memset(buffer, 0, SIZE); memset(buffer, 0, SIZE);
char* r = fgets(buffer, SIZE, stdin); char* r = fgets(buffer, SIZE, stdin);
if(r == NULL){ if(r == NULL){
printf("Expert z bufetu to vie.\n"); return 0;
printf("Chybna databaza\n");
return NULL;
} }
if (buffer[0] == '\n') { if (buffer[0] == '\n') {
return NULL; return 0;
} }
struct tree* tree = calloc(1, sizeof(struct tree)); struct tree* tree = calloc(1, sizeof(struct tree));
tree->value = malloc(strlen(buffer) + 1); tree->value = malloc(strlen(buffer) + 1);
@ -71,6 +69,9 @@ int main() {
printf("Pozna %d druhov ovocia a zeleniny.\n", counter); printf("Pozna %d druhov ovocia a zeleniny.\n", counter);
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
print_tree(root); print_tree(root);
} else{
printf("Expert z bufetu to vie.\n");
printf("Chybna databaza\n");
} }
destroy_tree(root); destroy_tree(root);
return 0; return 0;