/* * structs.c * * Computer Science 50, Fall 2011 * section6 * * Credit: Matthew Chartier * * Practice with structs. */ #include #include #include // define the pkmn struct with typedef typedef struct { char* name; char* type; int hp; bool cute; } pkmn; int main(void) { // create a new struct pkmn starter; // get pokemon's name printf("\nWhich pokemon do you want?\n"); starter.name = GetString(); printf("Good choice! %s is one of my favorites!\n", starter.name); // get pokemon's type printf("\nI seem to have misplaced my Pokedex.\n"); printf("What is %s's type?\n", starter.name); starter.type = GetString(); printf("That's right! %s is type %s!\n", starter.name, starter.type); // to keep the game fair starter.hp = 35; // cuteness evaluation if(strcmp("Pikachu", starter.name) == 0) starter.cute = true; else starter.cute = false; // print pokemon's information printf("\nYour Pokemon Journey Begins!\n"); printf("Name: %s\n", starter.name); printf("Type: %s\n", starter.type); printf("HP: %d\n", starter.hp); printf("Cute: %s\n", starter.cute ? "Yes" : "No"); printf("\nGood luck!\n"); // success return 0; }