/* names2.c -- passes and returns structures */ #include #include struct namect { char fname[20]; char lname[20]; int letters; }; struct namect getinfo(void); struct namect makeinfo(struct namect); void showinfo(struct namect); int main(void) { struct namect person; person = getinfo(); person = makeinfo(person); showinfo(person); return 0; } struct namect getinfo(void) { struct namect temp; printf("Please enter your first name.\n"); gets(temp.fname); printf("Please enter your last name.\n"); gets(temp.lname); return temp; } struct namect makeinfo(struct namect info) { info.letters = strlen(info.fname) + strlen(info.lname); return info; } void showinfo(struct namect info) { printf("%s %s, your name contains %d letters.\n", info.fname, info.lname, info.letters); }