如何对一个结构体初始化?
搜索更多相关的解决方案:
结构体
----------------解决方案--------------------------------------------------------
复制的
struct stu /*定义结构*/
{
int num;
char *name;
char sex;
float score;
} boy2,boy1={102,"Zhang ping",'M',78.5};
----------------解决方案--------------------------------------------------------
struct stu
{
int num;
char *name;
char sex;
float score;
}boy[5]={
{101,"Li ping","M",45},
{102,"Zhang ping","M",62.5},
{103,"He fang","F",92.5},
{104,"Cheng ling","F",87},
{105,"Wang ming","M",58};
}
----------------解决方案--------------------------------------------------------
当然你也可以在定义结构体变量时
----------------解决方案--------------------------------------------------------
学C++吧
这些玩意都是简单的
----------------解决方案--------------------------------------------------------
看一下书吧
----------------解决方案--------------------------------------------------------
struct stu /*定义结构*/
{
int num;
char *name;
char sex;
float score;
} boy[2];
for(i=0;i<2;i++)
scanf("%d%s%c%f",&boy[i].num,&boy[i].name,&boy[i].sex,&boy[i].score);
这样也行
----------------解决方案--------------------------------------------------------