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