结构体数组表示

定义结构体数组并初始化结构体成员

#include <stdio.h>
struct stud{

	int num;
	char *name;
	char sex;
	float score;
}boy[3]={
	{101,"Li Ping",'M',45},
	{102,"Zhang Ping",'M',62.5},
	{103,"He fang",'F',92.5}
};
void main(){
	for (int i=0;i<3;i++)
	{
		printf("%d %s %c %.2f\n",boy[i].num,boy[i].name,boy[i].sex,boy[i].score );
	}
}
posted @ 2018-09-26 09:24  Philtell  阅读(172)  评论(0编辑  收藏  举报