结构体 三 结构体数组
#include "stdio.h"
#include "assert.h"
#include "string.h"
#define NAME_LEN 20
//结构数组
struct student{
int age;
char sex;
};
struct student WritDate( const char*name, int id, int age);
int main()
{
struct student stu[10]=
{ {34,'Y'}, {23,'M'}, {55,'Y'}, {55,'Y'}, {55,'Y'},
{34,'Y'}, {23,'M'}, {55,'Y'}, {55,'Y'}, {55,'Y'}
};
// 为了显示数组中的某个零件,可以使用下标方式
PrintStu(stu[2]);
stu[0].age = 23;
PrintStu(stu[0]);
printf("\nHello world !\n");
return 0;
}
void PrintStu(struct student stu)
{
printf("%d,%c\n",stu.age,stu.sex);
}