Posted on 2007-07-02 22:14
停留的风 阅读(238)
评论(0) 编辑 收藏 所属分类:
C语言学习历程
//演示结构数组
#include <stdio.h>
int main(void)
{
int i;
struct month
{
int numberOfDays;
char name[3];
};
const struct month months[6]=
{
{31,{'J','a','n'}},{28,{'F','e','b'}},
{31,{'M','a','r'}},{30,{'A','p','r'}},
{31,{'M','a','y'}},{30,{'J','u','n'}},
};
printf("Month Number of Days\n");
printf("--------------------\n");
for(i=0;i<6;i++)
{
printf("%c%c%c %i\n",months[i].name[0],months[i].name[1],months[i].name[2],months[i].numberOfDays);
}
return 0;
}
运行图: