1.首先定义结构体数组:
typedef struct BleAndTspRmtCmd{
char terminal[3];
char note[3];
char rmtCmd[10];
char cmdPropt[24];
};
BleAndTspRmtCmd为结构体名,可以通过这个结构体名定义其他结构体变量,struct BleAndTspRmtCmd variable;
或者定义结构体数组变量,struct BleAndTspRmtCmd variable[];
2.或者定义全局结构体变量,
typedef struct {
char terminal[3];
char note[3];
char rmtCmd[10];
char cmdPropt[24];
}BleAndTspRmtCmd;
然后根据这个结构体变量定义其他结构体变量,BleAndTspRmtCmd variable;或者数组变量BleAndTspRmtCmd variable[];
3.初始化结构体方法:
方法一:定义结构体数组变量的时候直接初始化(赋值),因为结构体内变量为字符数组,也就相当于字符串指针,这是字符数组的特殊性。
struct BleAndTspRmtCmd myRmdCmdSet[28] = { {"XX", "XX", "XX", "XX"}, {"XX", "XX", "XX", "XX"}..