#include<stdio.h>
int main(){
struct Person{
char *name;
int age;
char *status;
}per={"张三",18};
/*
printf("name=%s",age=%d\n",per.name,per.age);
struct Person *p=&per;
printf("name=%s,age=%d\n",p->name,p->age);
*/
struct Person f={"成龙",60,"老爸"};
struct Person m={"林凤娇",58,"老妈"};
struct Person s={"房祖名",30,"龙太子"};
struct Person pers[3]={f,m,s};
for (int i=0; i<3;i++){
struct Person *p=pers+i;
printf("name=%s,age=%d,status=%s\n",p->name,p->age,p->status);
}
return 0;
} |
|