/* structs_1.c create a struct definition declare, initialize and print an automatic struct variable use of the . notation Tim Hoffman F03-15113 */ #include #include #include typedef struct { char *name; int year; /* 1=frosh, 2=soph etc */ } Person; /* Person is now a data type */ int main( int argc, char *argv[]) { Person p; p.name = malloc( strlen("Herman Munster") +1 ); /* malloc the name string */ strcpy( p.name,"Herman Munster" ); p.year = 4; printf("name %s, year %d\n", p.name, p.year ); free( p.name ); /* no garbage */ return 0; } /* EOF */