结构体数组 初始化(转)

结构体定义形式三种:

1.间接定义

struct

student

{

int num;

char name[20];

};

struct student[2];

 

2.直接定义

struct

student

{

int num;

char name[20];

}stu[2];

 

3. 无名定义

struct

{

int num;

char name[20];

}stu[2];

 

结构体数组初始化:

1,顺序初始化:

struct stu[]={200101,"xiaoming",200102,xiaoqiang,200105,"xiaohua"};

2.分行初始化: 添加大括号

struct stu[]={ {200101,"xiaoming"}, {200102,xiaoqiang},{200105,"xiaohua"}};

 

总结:

上面红色字样初始化是对的。

 

 

http://wenku.baidu.com/link?url=xz4FO_lif7yRUK4uPVvAkyh9Lo-beVy5H1mJcCalGdmmZJKlC4qqa6Kse936RNOCa9qqf94_9HTMWOe6ST_OETa85ebJqYgejTBKvOCDWna

posted on 2014-03-31 17:27  efforts and success  阅读(530)  评论(0编辑  收藏  举报

导航