当前位置:网站首页>【C language】typedef的使用:结构体、基本数据类型、数组
【C language】typedef的使用:结构体、基本数据类型、数组
2022-08-09 11:03:00 【XV_】
typedef基本数据类型
typedef int a;
a abc;
后面的a abc
就等价于int abc
typedef结构体
typedef
struct a {
int a;
int b;
}
abc;
abc aaa;
对于上述,abc aaa;
就等价于struct a aaa;
简而言之,typedef的本质,就是构建等价关系。
第一个例子,让a
和int
等价;
第二个例子,让abc
和struct a { int a; int b; };
等价;
这样一来,简化书写。
不过也有特别的例子,就是使用数组的时候。
typedef数组
typedef int a[5];
a aa;
这里a aa
等价于int aa[5]
,这里aa的本质,是具有5个元素的int类型数组。
也就是说,typedef int a[5];
,使得a
与int[5]
等价,当然C语言没有这样的写法,希望能够理解,a
就是代表具有5个int类型元素的数组。
typedef struct desc_struct
{
unsigned long a, b;
}
desc_table[256];
desc_table idt, gdt;
这里idt
就是struct desc_struct idt[256]
,gdt
同理。
边栏推荐
猜你喜欢
随机推荐
The complete grammar of CSDN's markdown editor
MySQL传统方案和通过SSH连接哪个好?
剖析STM32F103时钟系统
性能测试(01)-jmeter元件-线程组、调试取样器
pip常见命令和更改源文件
electron 应用开发优秀实践
caffe ---make all editing error
∘(空心的点乘)的数学含义
Qt 国际化翻译
CSDN的markdown编辑器语法完整大全
gdb 10.2的安装
绝了,这套RESTful API接口设计总结
String类型的字符串对象转实体类和String类型的Array转List
Netscope:神经网络结构在线可视化工具
Jmeter BeanShell post processor
MATLAB中如何把cftool拟合的函数输出到命令行(解决如何导出拟合后的曲线数据)
Looper 原理浅析
CentOS6.5 32bit安装Oracle、ArcSde、Apache等配置说明
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
性能测试(05)-表达式和业务关联-json关联