当前位置:网站首页>C专家编程 第3章 分析C语言的声明 3.6 typedef int x[10]和#define x int[10]的区别
C专家编程 第3章 分析C语言的声明 3.6 typedef int x[10]和#define x int[10]的区别
2022-08-03 16:09:00 【weixin_客子光阴】
3.6 typedef int x[10]和#define x int[10]的区别
/*typedef看成是一种彻底的“封装”类型----在声明它之后不能再往里面增加别的
*内容,可以用其他类型说明符对宏类型名进行扩展,但对typedef所定义的类型却不能那样做
*/
#define peach int
unsigned peach i; /*没问题*/
typedef int banana;
unsigned banana i; /*错误!非法*/
/*在几个连续的变量的声明中,用typedef定义的类型能够保证声明中所有的变量均为
*同一种类型,而用#define定义的类型却无法保证
*/
#define int_ptr int *
int_ptr chalk, cheese;
相当于
int *chalk, cheese;
typedef char * char_ptr;
char_ptr Bentley, Rolls_Royce;
相当于
char * Bentley, *Rolls_Royce;
边栏推荐
猜你喜欢

Not to be ignored!Features and advantages of outdoor LED display

《社会企业开展应聘文职人员培训规范》团体标准在新华书店上架

【Unity入门计划】基本概念(6)-精灵渲染器 Sprite Renderer

Cookie和Session的关系

【899. Ordered Queue】

AI+BI+Visualization, Deep Analysis of Sugar BI Architecture
![[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 02](/img/45/96af4ca21329964808a4c8f2b8272c.png)
[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 02

Yii2安装遇到Loading composer repositories with package information
![[QT] Qt project demo: data is displayed on the ui interface, double-click the mouse to display specific information in a pop-up window](/img/3f/265c9d2703056260e03c346fa65a03.png)
[QT] Qt project demo: data is displayed on the ui interface, double-click the mouse to display specific information in a pop-up window

为教育插上数字化的翅膀,网易云信发布「互联网+教育」整体解决方案
随机推荐
使用Make/CMake编译ARM裸机程序(基于HT32F52352 Cortex-M0+)
字典表(还需要输入2个字)
如何启动 NFT 集合
请问下,flink cdc监控oracle,我看源码是通过sid方式的,请问怎么改成service
Introduction to the advantages of the new generation mesh network protocol T-Mesh wireless communication technology
13、OOM模拟
简易网络传输方法
【Unity入门计划】基本概念(8)-瓦片地图 TileMap 02
【带你了解SDN和网络虚拟化】
视频人脸识别和图片人脸识别的关系
Introduction to spark learning - 1
Cookie和Session的关系
MATLAB | 一种简易的随机曼陀罗图形生成函数
leetcode-268.丢失的数字
[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 01
2021年数据泄露成本报告解读
Kubernetes 笔记 / 入门 / 生产环境 / 用部署工具安装 Kubernetes / 用 kubeadm 启动集群 / 安装 kubeadm
30W 2C(JD6606S + FP6652X2)BOM
用友YonSuite与旺店通数据集成对接-技术篇2
MySQL窗口函数 PARTITION BY()函数介绍