main()
{
struct student
{int num;
char name[20];
char sex[6];
int age;
};
struct student a;
a={103,"wei zhiliang","male",29};
}
main()
{
struct student
{int num;
char name[20];
char sex[6];
int age;
};
struct student a;
a={103,"wei zhiliang","male",29};
}
上面的方法不行,下面的就可以
struct student a={103,"wei zhiliang","male",29};
}
另外结构体赋值要在函数内赋值。函数外赋值编译阶段无法识别自定义的数据类型导致无法赋值。