来自江协科技
c语言结构体
typedef struct(char x; int y; float z) structName;//其中typedef是关键字,用于将一个比较长的变量类型换个名字,typedefine A B,在后面用B来代替A。 struct()代表一个数据结构体,括号内是这一个结构体所含的的数据集合,structName是该结构体的名字,在后面可以用structName来代替这一个数据集合。
structName c;//给该结构体变量命名为c
c.x='A';
c.y=66;
c.z=1.23;//给该结构体内部数据变量赋值
stm32中
typedef struct
{uint16_t GPIO_Pin;
GPIOSpeed_TypeDef GPIO_Speed;
GPIOMode_TypeDef GPIO_Mode;
}GPIO_InitTypedeff
\\引入三个数据类型uint16_t、GPIOMode_TypeDef、GPIO_InitTypeDef,分别将其数据名称命名为GPIO_Pin、GPIO_Speed、GPIO_Mode,把这三种数据类型集合在GPIO_InitTypedeff这个结构体中。
GPIO_InitTypeDef GPIO_InitStructure;//给该结构体命名为GPIO_InitStructure
GPIO_InitStructure.GPIO_Pin=
GPIO_InitStructure.GPIO_Speed=
GPIO_InitStructure.GPIO_Mode=
//再自行定义该结构体内部数据变量的值
(笔记)