// Demonstration of structs and enums together // Lets define enum for pokemon type // Lets define a struct for a pokemon // Lets create a variable for a pokemon and give it some data // Lets print out the data #include enum pokemon_type {FAIRY, FIRE, WATER, NORMAL}; struct pokemon { int hit_points; double combat_power; double speed; enum pokemon_type primary_type; enum pokemon_type secondary_type; }; void print_pokemon_type(enum pokemon_type type); void print_pokemon(struct pokemon my_pokemon); int main(void) { struct pokemon jigglypuff; jigglypuff.hit_points = 80; jigglypuff.combat_power = 40; jigglypuff.speed = 1004.5; jigglypuff.primary_type = FAIRY; jigglypuff.secondary_type = NORMAL; print_pokemon(jigglypuff); return 0; } void print_pokemon_type(enum pokemon_type type) { if (type == FAIRY) { printf("Fairy"); } else if (type == FIRE) { printf("Fire"); } else if (type == WATER) { printf("Water"); } else if (type == NORMAL) { printf("Normal"); } else { printf("Unknown Type"); } printf("\n"); } void print_pokemon(struct pokemon my_pokemon) { printf("Pokemon Stats\n"); printf("Hit Points: %d\n", my_pokemon.hit_points); printf("Combat Power: %lf\n", my_pokemon.combat_power); printf("Hit_points: %lf\n", my_pokemon.speed); print_pokemon_type(my_pokemon.primary_type); print_pokemon_type(my_pokemon.secondary_type); }