//用结构体数组指针完成:有三个学生信息,存放在结构体数组中,要求输出全部信息 #include <stdio.h> struct Stu { int num; char name[20]; char sex; int age; }; int main() { struct Stu student[3]={{317,"han",'m',20},{318,"hun",'w',22},{311,"dan",'w',18}}; struct Stu *p; printf(" num name sex age\n"); for(p=student;p<student+3;p++) { printf("%5d %s %c %d\n",p->num,p->name,p->sex,p->age); } return 0; }
时间: 2024-10-05 04:45:17