#include #include "animals.h" #include "vector.h" #include int main(){ // ================= FISH =============== /* struct fish *f = fish_init("Salmon", 10, 5, 1); printf("Fish species: %s\n", f->species); printf("Swimming speed: %d\n", f->swimming_speed); printf("Size: %zu\n", f->size); printf("Lives in fresh water: %d\n", f->lives_in_fresh_water); free_fish(f); */ /* struct fish *f = fish_init("Trout", 8, 4, 1); struct animal *a = animal_from_fish("Blue", f); printf("Animal type: %d\n", a->type); printf("Animal color: %s\n", a->color); printf("Fish species from animal: %s\n", a->animal.fish->species); free_fish(f); free(a->color); free(a); */ /* struct fish *f = fish_init("Carp", 6, 3, 0); free_fish(f); */ // ================ INSECT ============== /* struct insect *i = insect_init("Dragonfly", 2, 1, 0); printf("Insect species: %s\n", i->species); printf("Size: %zu\n", i->size); printf("Can fly: %d\n", i->can_fly); printf("Can swim: %d\n", i->can_swim); free(i->species); free(i); */ /* struct insect *i = insect_init("Butterfly", 1, 1, 0); struct animal *a = animal_from_insect("Yellow", i); printf("Animal type: %d\n", a->type); printf("Animal color: %s\n", a->color); printf("Insect species from animal: %s\n", a->animal.insect->species); free(i->species); free(i); free(a->color); free(a); */ /* struct insect *i = insect_init("Beetle", 3, 0, 1); free_insect(i); */ // ============ VECTOR ============== /* struct vector *v = vector_init(5); printf("Initial size: %zu\n", v->size); printf("Initial capacity: %zu\n", v->capacity); free(v->animal); free(v); */ /* struct vector *v = vector_init(2); v = vector_resize(v, 4); printf("Resized capacity: %zu\n", v->capacity); free(v->animal); free(v); */ /* struct vector *v = vector_init(2); struct fish *f1 = fish_init("Salmon", 10, 5, 1); struct animal *a1 = animal_from_fish("Blue", f1); v = vector_append(v, a1); struct fish *f2 = fish_init("Trout", 8, 4, 1); struct animal *a2 = animal_from_fish("Green", f2); v = vector_append(v, a2); struct fish *f3 = fish_init("Carp", 6, 3, 0); struct animal *a3 = animal_from_fish("Red", f3); v = vector_append(v, a3); printf("Vector size after appends: %zu\n", v->size); printf("Vector capacity after appends: %zu\n", v->capacity); free(f1->species); free(f1); free(a1->color); free(a1); free(f2->species); free(f2); free(a2->color); free(a2); free(f3->species); free(f3); free(a3->color); free(a3); free(v->animal); free(v); */ /* struct fish *f = fish_init("Salmon", 10, 5, 1); struct animal *a = animal_from_fish("Blue", f); free_animal(a); */ struct vector *v = vector_init(5); struct fish *f = fish_init("Trout", 8, 4, 1); struct animal *a = animal_from_fish("Green", f); v = vector_append(v, a); vector_destroy(v); }