当前位置:网站首页>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]
边栏推荐
- “京台高铁”亮相百度地图,真能在2035年建成吗?
- ifconfig与ip命令的比较
- Talk about the understanding of RPC
- Meaning of df and df -lh
- 什么是三方支付?
- Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
- IDE编译报错:Dangling metacharacter
- The most unlucky and the luckiest
- ESP32的环境配置(arduino arduino2.0 VScode platform哪个好用?)
- Briefly, talk about the use of @Transactional in the project
猜你喜欢
DOM树的遍历-----修改样式,选择元素,创建和删除节点
Google search skills - programmer is recommended
leetcode: 358. Reorder strings at K distance intervals
leetcode:358. K 距离间隔重排字符串
解决vim与外界的复制粘贴(不用安装插件)
Vim and copy and paste from the outside (don't need to install the plugin)
OpenCV founder: Open source must not be completely free!
CSAPP Data Lab
AI+Medical: Using Neural Networks for Medical Image Recognition and Analysis
关于地图GIS的一次实践整理(下) Redis的GIS实践
随机推荐
求和、计数的窗口函数应用
Goodbye Chengdu paper invoices!The issuance of electronic invoices for accommodation expenses will soon completely replace the invoices of hotels, catering and gas stations
增加对 Textbundle 的支持
(CVPR-2017)在身体和潜在部位学习深度上下文感知特征以进行行人重识别
Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
rac备库双节点查询到的表最后更新时间不一致
CSAPP Data Lab
二叉树相关代码题【较全】C语言
分布式和集群的区别和联系
Typescript学习笔记 | 字节青训营笔记
The problem that Merge will be lost again after code Revert has been solved
ROS源代码阅读(1)
JS-DOM element object
基于改进YOLOv5轻量化的烟火检测
JS-DOM元素对象
对加密世界的经济误解:现金是储蓄?稀缺性创造价值?
今天聊聊接口幂等性校验
Talk about the understanding of RPC
获取链表长度
AI+Medical: Using Neural Networks for Medical Image Recognition and Analysis