This commit is contained in:
Denis Landa 2025-11-20 20:58:16 +01:00
parent 36a36be66e
commit d7cecb13a7

View File

@ -11,14 +11,14 @@ struct tree{
}; };
struct tree* read_tree(){ struct tree* read_tree(){
char buffer[SIZE]; char b[SIZE];
if(!fgets(buffer,SIZE,stdin)) return NULL; if(!fgets(b,SIZE,stdin)) return NULL;
if(buffer[0]=='\n') return NULL; if(b[0]=='\n') return NULL;
struct tree* t=malloc(sizeof(struct tree)); struct tree* t=malloc(sizeof(struct tree));
strcpy(t->text,buffer); strcpy(t->text,b);
t->yes=NULL; t->yes=NULL;
t->no=NULL; t->no=NULL;
if(buffer[0]=='*') return t; if(b[0]=='*') return t;
t->yes=read_tree(); t->yes=read_tree();
t->no=read_tree(); t->no=read_tree();
return t; return t;
@ -38,12 +38,13 @@ int count_items(struct tree* t){
} }
void run_chatbot(struct tree* t){ void run_chatbot(struct tree* t){
printf("%s",t->text);
if(t->text[0]=='*'){ if(t->text[0]=='*'){
printf("%s",t->text);
printf("Koniec\n"); printf("Koniec\n");
return; return;
} }
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
printf("%s",t->text);
char c; char c;
if(scanf(" %c",&c)!=1){ if(scanf(" %c",&c)!=1){
printf("Chyba vstupu.\n"); printf("Chyba vstupu.\n");