Initializacia
This commit is contained in:
parent
e548847f2e
commit
192ea219b4
@ -33,7 +33,6 @@ struct tree* load_tree() {
|
|||||||
node->right = load_tree();
|
node->right = load_tree();
|
||||||
} else if (node->left != NULL || node->right != NULL) {
|
} else if (node->left != NULL || node->right != NULL) {
|
||||||
printf("Expert z bufetu to vie.\n");
|
printf("Expert z bufetu to vie.\n");
|
||||||
printf("Chybna databaza\n");
|
|
||||||
free(node);
|
free(node);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -89,12 +88,22 @@ void count_items(struct tree* tree, int* count) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
struct tree* root = load_tree();
|
struct tree* root = load_tree();
|
||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
|
printf("Chybna databaza\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Expert z bufetu to vie.\n");
|
printf("Expert z bufetu to vie.\n");
|
||||||
|
|
||||||
|
// Check if the input is empty after loading the tree
|
||||||
|
char buffer[SIZE];
|
||||||
|
if (fgets(buffer, SIZE, stdin) == NULL || buffer[0] == '\n') {
|
||||||
|
printf("Chybna databaza\n");
|
||||||
|
destroy_tree(root);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
count_items(root, &count);
|
count_items(root, &count);
|
||||||
printf("Pozna %d druhov ovocia a zeleniny.\n", count);
|
printf("Pozna %d druhov ovocia a zeleniny.\n", count);
|
||||||
|
Loading…
Reference in New Issue
Block a user