cv7
This commit is contained in:
parent
8d15749214
commit
00f8a74436
@ -15,11 +15,18 @@ struct tree* read_tree(int* counter) {
|
||||
memset(buffer, 0, SIZE);
|
||||
char* r = fgets(buffer, SIZE, stdin);
|
||||
if (buffer[0] == '\n') {
|
||||
printf("Chybna databaza\n");
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
struct tree* tree = calloc(1, sizeof(struct tree));
|
||||
if(tree == NULL){
|
||||
printf("Chybna databaza\n");
|
||||
exit(0);
|
||||
}
|
||||
tree->value = malloc(strlen(buffer) + 1);
|
||||
if(tree->value == NULL){
|
||||
printf("Chybna databaza\n");
|
||||
exit(0);
|
||||
}
|
||||
strcpy(tree->value, buffer);
|
||||
if (buffer[0] == '*') {
|
||||
(*counter)++;
|
||||
@ -63,6 +70,7 @@ int main() {
|
||||
int counter = 0;
|
||||
struct tree* root = read_tree(&counter);
|
||||
printf("Expert z bufetu to vie.\n");
|
||||
|
||||
printf("Pozna %d druhov ovocia a zeleniny.\n", counter);
|
||||
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||
print_tree(root);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user