nevidel som ze segmentation fault
This commit is contained in:
parent
c130b99678
commit
a0fa5c7f11
@ -42,6 +42,11 @@ void spustac(struct uzol* uzol) {
|
|||||||
if (uzol == NULL) return; // ak nemam strom koncim
|
if (uzol == NULL) return; // ak nemam strom koncim
|
||||||
printf ("%s",uzol -> otazka); // vypisem content textu struktury
|
printf ("%s",uzol -> otazka); // vypisem content textu struktury
|
||||||
|
|
||||||
|
if (uzol -> pravy == NULL && uzol -> lavy == NULL) { // ak nema pokracovanie, napisem ze nema pokracovanie
|
||||||
|
printf ("Koniec\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char odpoved; // iacitavam a/n
|
char odpoved; // iacitavam a/n
|
||||||
scanf(" %c",&odpoved);
|
scanf(" %c",&odpoved);
|
||||||
|
|
||||||
@ -51,14 +56,12 @@ void spustac(struct uzol* uzol) {
|
|||||||
spustac (uzol -> pravy);
|
spustac (uzol -> pravy);
|
||||||
} // uvidim co test ocakava ked dam zle odpoved
|
} // uvidim co test ocakava ked dam zle odpoved
|
||||||
|
|
||||||
if (uzol -> pravy == NULL && uzol -> lavy == NULL) { // ak nema pokracovanie, napisem ze nema pokracovanie
|
|
||||||
printf ("Koniec\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy_tree (struct uzol* strom){
|
void destroy_tree (struct uzol* strom){
|
||||||
|
if (strom == NULL) return;
|
||||||
destroy_tree(strom -> lavy);
|
destroy_tree(strom -> lavy);
|
||||||
destroy_tree(strom -> pravy);
|
destroy_tree(strom -> pravy);
|
||||||
free(strom);
|
free(strom);
|
||||||
@ -78,7 +81,7 @@ int main() {
|
|||||||
|
|
||||||
spustac(strom);
|
spustac(strom);
|
||||||
|
|
||||||
if (strom != NULL) destroy_tree(strom);
|
destroy_tree(strom);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user