/*
用结构体定义一个三口之家,家里每个成员都有:姓名,年龄,身份(如:父亲).
*/
#include <stdio.h>
int main(){
struct Person{
char *name;
int age;
char *shenFen;
};
struct Person f={"成龙",60,"father"};
struct Person m={"林凤娇",58,"mother"};
struct Person s={"房祖名",30,"son"};
struct Person a[3]={f,m,s};
for(int i=0;i<3;i++){
printf("%s---%d---%s\n",a[i].name,a[i].age,a[i].shenFen);
}
return 0;
} |
|