/* struct1.c how to pass a structure to a function */ #include #include #define NAME_LEN 40 struct person { char name[NAME_LEN+1]; float height; }; void initPerson( struct person *p, char *name, float height ); void printPerson( struct person * ); int main( void ) { struct person p; initPerson( &p,"suzanne",60.0 ); printPerson( &p ); } // end of main() void initPerson( struct person *p, char *name, float height ) { strcpy( p->name,name ); p->height = height; } // end of initPerson() void printPerson( struct person *p ) { printf( "name = [%s]\n",p->name ); printf( "height = %5.2f inches\n",p->height ); } // end of printPerson()