#include #include "army.h" struct node { struct node* next; struct monster* monster; }; struct army { struct node* monsters; int stars; }; struct army* new_army() { struct army* res = malloc(sizeof(*res)); res->monsters = NULL; res->stars = 0; return res; } void add_monster_to_army(struct army* army, struct monster* monster) { struct node* node = malloc(sizeof(*node)); node->next = army->monsters; node->monster = monster; army->monsters = node; } void print_army(struct army* army) { printf("This is a %d stars army\n", army->stars); for(struct node* cur = army->monsters; cur != NULL; cur = cur->next) print_monster(cur->monster); } void delete_nodes(struct node* node) { if(node != NULL) { delete_nodes(node->next); free(node); } } void delete_army(struct army* army) { delete_nodes(army->monsters); free(army); }