#include <stdio.h>
#include <string.h>
struct namect{
char fname[20];
char lanme[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.lanme);
return temp;
}
struct namect makeinfo(struct namect info){
info.letters=strlen(info.fname)+strlen(info.lanme);
return info;
}
void showinfo(struct namect info){
printf("%s %s,your name contains %d letters.\n",info.fname,info.lanme,info.letters);
}
本文转sinojelly51CTO博客,原文链接:http://blog.51cto.com/pnig0s1992/409802,如需转载请自行联系原作者