truct student char name[201 char sex float score sl={"12004","李明",m,19,298.3}, s2={"12005”;王丽",,18.,227.9},p=&sl printf("学号姓名性别年龄分数n") printf("\n"); printf("%s %s %c %d %f\n p->number, p->name, p->sex, p->age, p->score) p=&s2 体*指针p指向s2*/ printf("%s %s %c %d %f\n p->number, p->name, p->sex, p->age, p->score)
main() { struct student { char number[6]; char name[20]; char sex; int age; float score; }s1={"12004","李明",'m',19,298.3}, s2={"12005","王丽",'f',18,227.9},*p=&s1; printf("学号 姓名 性别 年龄 分数\n"); printf("\n"); printf("%s %s %c %d %f\n", p->number,p->name,p->sex,p->age,p->score); p=&s2; /*指针 p 指向 s2*/ printf("%s %s %c %d %f\n", p->number,p->name,p->sex,p->age,p->score); }