Initializacia
This commit is contained in:
parent
72e5b20347
commit
2b3c70feac
@ -29,15 +29,18 @@ struct tree* read_tree() {
|
||||
struct tree* load_tree() {
|
||||
struct tree* node = read_tree();
|
||||
if (!node) {
|
||||
error_flag = 1;
|
||||
return NULL;
|
||||
}
|
||||
if (node->value[0] != '*') {
|
||||
node->left = load_tree();
|
||||
if (error_flag) return node;
|
||||
node->right = load_tree();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void run_tree(struct tree* tree) {
|
||||
if (!tree) {
|
||||
return;
|
||||
@ -55,11 +58,7 @@ void run_tree(struct tree* tree) {
|
||||
printf("Koniec vstupu\n");
|
||||
return;
|
||||
}else if (response != 'a' && response != 'n') {
|
||||
if (feof(stdin)) {
|
||||
printf("Chybna databaza\n");
|
||||
} else {
|
||||
printf("Nerozumiem\n");
|
||||
}
|
||||
printf("Nerozumiem\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,8 +94,9 @@ void count_items(struct tree* tree, int* count) {
|
||||
int main() {
|
||||
struct tree* root = load_tree();
|
||||
printf("Expert z bufetu to vie.\n");
|
||||
if (!root) {
|
||||
if (!root || error_flag) {
|
||||
printf("Chybna databaza\n");
|
||||
destroy_tree(root);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ int main() {
|
||||
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||
|
||||
run_tree(root);
|
||||
|
||||
destroy_tree(root);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user