结构体基本操作
#include<stdio.h>
#include<string.h>
struct Student
{
int age;
char name[50];
int score;
};//注意有分号
int main()
{
//定义结构体变量
struct Student stu;
//结构体变量的初始化,和数组一样,要使用大括号
//只有在定义时,才能初始化
struct Student st2 = {18,"mil",30};
//使用结构体成员,需要使用结构体变量来引用
//如果是普通变量,使用. 点运算符
//如果是指针变量,使用指针->操作
struct Student st3;
st3.age = 18;
strcpy(st3.name,"mike");//name是数组名,是个常量,不能修改
st3.score = 59;
struct Student *p;
*p = &st3;
p->age = 18;
//等价于 (*p).age = 18;//点的优先级更高,得加括号
p->score = 60;
strcpy(p->name,"nkif");
//任何结构体都可以. 或 ->操作成员
(&st3)->age = 18;
( *p).age = 20;
}