参考链接:https://www.runoob.com/cprogramming/c-typedef.html

作用

typedef是用来为数据类型(可以是各种数据类型,包括自己定义的数据类型如结构体)定义别名的,比如为单字节数字取一个别名

typedef unsigned char BYTE;//一般大写为规范
unsigned char b1;//下面这两个作用是一样的
BYTE b1;

#define和typedef的不同

#define也是C提供的用于为数据类型定义别名的
1.#define可以为各种数据类型定义别名,包括为数值定义别名(但多个的话会选择用枚举实现)而typedef只能为数据类型定义别名
2.#define 语句是由预编译器处理的,而typedef是由编译器进行解释

相关文章:

  • 2021-06-05
  • 2021-05-22
  • 2021-09-15
  • 2021-06-01
  • 2022-12-23
  • 2021-05-19
  • 2021-10-14
  • 2021-05-17
猜你喜欢
  • 2021-07-27
  • 2021-06-15
  • 2021-06-04
  • 2022-01-15
  • 2021-07-13
  • 2021-07-26
  • 2022-12-23
相关资源
相似解决方案