结构体数组定义

结构体数组
    结构体数组的定义:具有相同结构体类型的结构体变量组成的数组
   定义结构体数组的方法和定义结构体变量的方法类似。

eg:

#include
#include
#define N 10
struct student
 {
	int SID;
	char name[N];
	float score;
 } s2[2]; 

int main()
{
 int i;
 struct student s1[2]={{1,"s1",99},{2,"s2",88}};
 printf("  %d %s %.2f\n",s1[0].SID,s1[0].name,s1[0].score);
 int len=sizeof(s2)/sizeof(struct student);//求结构体数组长度
 for(i=0;i

 

结果:结构体数组定义_第1张图片

你可能感兴趣的:(C语言)