结构体指针和typedef的使用
一、结构体指针
一个结构体变量的指针就是该变量所占据的内存段的起始地址。
可以设置一个指针变量,用它指向一个结构体变量,此时该指针变量的值是结构体变量的起始地址。
指针变量也可以用来指向结构体数组中的元素,从而能够通过结构体指针快速访问结构体内的每个成员。
// Created by zjc on 2024/8/7 16:38
#include "stdio.h"
struct student{
int num;
char name[10];
char sex;
};
int main(){
// 定义结构体变量,并且赋值
struct student s={
1001,"wangle",'M'};
struct student sarr[3]={
1001,"lilei",'M',
1005,"zhangsan",