This commit is contained in:
Damián Korpesio 2021-11-25 16:20:34 +01:00
parent af8e949818
commit 87375cad1d

View File

@ -1,9 +1,9 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 50
#define LINESIZE 50
struct tree{
char question[SIZE];
char question[LINESIZE];
struct tree* left;
struct tree* right;
};
@ -19,8 +19,8 @@ int main(){
struct tree* root = NULL;
root = read_tree();
char resp[SIZE];
memset(resp,0,SIZE);
char resp[LINESIZE];
memset(resp,0,LINESIZE);
get_input(resp);
if(strlen(resp)>1){
printf("Expert z bufetu to vie.\n");
@ -45,8 +45,8 @@ int main(){
struct tree* read_tree(){
char buffer[SIZE];
memset(buffer,0,SIZE);
char buffer[LINESIZE];
memset(buffer,0,LINESIZE);
int flag = get_input(buffer);
if(flag==-1){
@ -56,7 +56,7 @@ struct tree* read_tree(){
}
struct tree* node = calloc(1,sizeof(struct tree));
memcpy(node->question,buffer,SIZE);
memcpy(node->question,buffer,LINESIZE);
if(node->question[0]!='*'){
node->left = read_tree();
node->right = read_tree();
@ -66,7 +66,7 @@ struct tree* read_tree(){
int get_input(char *string){
char* r = fgets(string,SIZE,stdin);
char* r = fgets(string,LINESIZE,stdin);
if(r==NULL){
return -1;
}
@ -83,7 +83,7 @@ void system_execute(struct tree* root){
if(root->question[0]=='*'){
return;
}
char *resp = calloc(SIZE,sizeof(char));
char *resp = calloc(LINESIZE,sizeof(char));
int flag = get_input(resp);
if(flag==-1){