#include /* * show how to use functions with structs * 1. a less efficient way * 2. a typical, better way */ #define NAME_LEN 100 #define NUM_LEN 30 struct contact { char name[NAME_LEN]; char phonenum[NUM_LEN]; }; void fill_entry(struct contact *); void print_entry(struct contact); int main() { struct contact alan; fill_entry(&alan); // &alan is ADDRESS of the variable print_entry(alan); return 0; } void fill_entry( struct contact *cp ) { printf("name? "); scanf("%s", cp->name ); printf("phone num? "); scanf("%s", cp->phonenum ); } void print_entry( struct contact c ) { printf("name: %s\n", c.name); printf("phone num: %s\n", c.phonenum); }