// 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; }; 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; printf("Pokemon Stats\n"); printf("Hit Points: %d\n", jigglypuff.hit_points); printf("Combat Power: %lf\n", jigglypuff.combat_power); printf("Hit_points: %lf\n", jigglypuff.speed); if (jigglypuff.primary_type == FAIRY) { printf("Fairy"); } else if (jigglypuff.primary_type == FIRE) { printf("Fire"); } else if (jigglypuff.primary_type == WATER) { printf("Water"); } else if (jigglypuff.primary_type == NORMAL) { printf("Normal"); } else { printf("Unknown Type"); } printf("\n"); if (jigglypuff.secondary_type == FAIRY) { printf("Fairy"); } else if (jigglypuff.secondary_type == FIRE) { printf("Fire"); } else if (jigglypuff.secondary_type == WATER) { printf("Water"); } else if (jigglypuff.secondary_type == NORMAL) { printf("Normal"); } else { printf("Unknown Type"); } printf("\n"); return 0; }