红联Linux门户
Linux帮助

请大虾解释一下C代码

发布时间:2011-10-10 13:06:55来源:红联作者:wmqj
[i=s] 本帖最后由 wmqj 于 2011-10-10 13:07 编辑 [/i]

请大虾给解释一下、谢谢
struct acorestruct
{
int math;
int English;
}score;(score这个声明结构体变量,启什么作用,请大虾指教,这不明白为什么要声明)
struct infostruct
{
float height;
float wight;
}info;(info这个声明结构体变量,启到什么作用,不写不行吗)[code]#include
#include
struct student
{
char name[20];
struct acorestruct
{
int math;
int English;
}score;
struct infostruct
{
float height;
float wight;
}info;
};
void main(void)
{
struct student lisi={"li si",{80,96},{175,80};
printf("lisi,s name;\n%s]n",lisi.name);
/*下在的就省略不写了*/
    getch();
}[/code]
文章评论

共有 6 条评论

  1. hongyu315 于 2011-10-11 10:31:57发表:

    just name

  2. lijiang 于 2011-10-11 09:47:33发表:

    [i=s] 本帖最后由 lijiang 于 2011-10-11 09:51 编辑 [/i]

    此C程序在一个大的结构体类型中嵌套定义了两个小结构体类型,分别用来存放两类数据。

  3. zly159 于 2011-10-10 17:01:20发表:

    顶顶顶顶顶顶顶顶顶顶顶

  4. 小举 于 2011-10-10 16:22:22发表:

    留着定义结构体变量的,就像int

  5. organization 于 2011-10-10 14:27:43发表:

    score和info是结构的名称,前面的是结构类型的定义。

  6. wmqj 于 2011-10-10 14:21:03发表:

    悔悟卡好贵(6)m:b