结构体入门赋值
#include<stdio.h>
struct student {
int a;
float f;
int b;
double c;
}student1;
struct teacher
{
int a;
int b;
double c;
struct student f;//这里是结构体成员
}teacher1;
int main()
{
//teacher1.f=123.456;//这样是错的
teacher1.f.f = 123.456;
printf("%f\n", teacher1.f.f);
teacher1.a = student1.a=2;//结构体赋值
teacher1.a++;//结构体自增
printf("%d\n", teacher1.a);
return 0;
}
结构体数组
struct student
{
int id;
int score;
char sex[10];
}student1[3] = { 01,99,"男" };
int main()
{
int i = 0;
printf("%d,%d,%s", student1[i].id,student1[i].score,student1[i].sex);
return 0;
}