当前位置:网站首页>typedef定义结构体数组类型
typedef定义结构体数组类型
2022-08-11 03:09:00 【family20102010】
PS: typedef定义的只是XX类型的别名(或标签),不能直接用作变量来使用,只能用它去定义变量。
例1:
typedef struct st
{
char id;
int num;
char name[10];
}DATA[10];//这里的DATA不是一个数组,它只表示是一个数组类型,程序中不能直接使用DATA[i]
DATA tmp;//相当于定义了一个数组 tmp[10],元素类型=结构体st,程序中可以直接使用tmp[i]
例2:
typedef struct {
word Head;
word Length;
byte PDUType;
byte SRC_ID[10];
byte DST_ID[10];
byte PDUdata[200];
}TReqFunReg, * PReqFunReg;
Typedef TreqFunReg reg[100];//注意:这里的reg只是表示一个数组类型,而不是数组,程序中不能直接使用reg[i],正确用法是用reg定义一个变量,这个变量就是有100个元素的数组了,且元素类型是结构体TreqFunReg。
TreqFunReg reg1[100];//这才是定义了一个结构体数组(没有Typedef修饰),程序中可以直接使用reg1[i]
reg aaa;//等价于 TreqFunReg aaa[100]; 程序中可以直接使用aaa[i]
边栏推荐
猜你喜欢

Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案

图解LeetCode——640. 求解方程(难度:中等)

多商户商城系统功能拆解26讲-平台端分销设置

索引的创建、查看、删除

Salesforce disbands the Chinese team, which CRM product is more suitable for the Chinese

DOM-DOM树,一个DOM树有三种类型的节点

CSDN 博客更换皮肤

How does MSP430 download programs to the board?(IAR MSPFET CCS)

Idea (preferred) cherry-pick operation

①CAS SSO单点登录框架源码深度分析
随机推荐
重庆纸质发票再见!开住宿费电子发票即将全面取代酒店餐饮加油站发票
关于地图GIS的一次实践整理(下) Redis的GIS实践
ES进阶 数组功能语法新特性详解
oracle的基数会影响到查询速度吗?
获取链表长度
21天学习挑战赛第一周总结
DOM-DOM树,一个DOM树有三种类型的节点
What does the sanction of the mixer Tornado mean for the DeFi market?
论文精度 —— 2017 CVPR《High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis》
Realization of vending machine function based on FPGA state machine
CSDN blog replacement skin
Summary of Logstash log data write exception troubleshooting
Briefly, talk about the use of @Transactional in the project
①In-depth analysis of CAS SSO single sign-on framework source code
IDE编译报错:Dangling metacharacter
"Beijing-Taiwan high-speed rail" debuted on Baidu map, can it really be built in 2035?
google搜索技巧——程序员推荐
CSAPP Data Lab
DOM-DOM tree, a DOM tree has three types of nodes
Ninjutsu_v3_08_2020-安全渗透系统安装