#include #include #include #define MAXLINE 80 #define NUMANIM 3 typedef struct { char name[MAXLINE]; int age; int numLegs; } animal; /*fn to print out all the zoo inhabitants */ /*this is pass by value as we make no changes to the data */ void printAnims(animal a[]) { int i; for (i=0; i < NUMANIM; i++) { printf("animal %d:\n", i); printf("\tname: %s\n", a[i].name); printf("\tage: %d\n", a[i].age); printf("\tlegs: %d\n", a[i].numLegs); } } int main(void) { animal zoo[NUMANIM]; int i; /* initialization */ for (i=0; i < NUMANIM; i++) { strcpy(zoo[i].name, "penguins"); zoo[i].age = 1; zoo[i].numLegs = 2; } printf("The animals in the zoo upon initialization\n"); printAnims(zoo); return 0; }