typedef是在计算机编程语言中用来为复杂的声明定义简单的别名,可以是内部数据类型也可以是自定义数据类型。
定义:
typedef <已有数据类型> <新数据类型>;
如:
typedef int INTEGER;
这里新定义了数据类型INTEGER, 其等价于int
INTEGER i; <==> int i;
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
struct struct_t {
int status;
};
typedef unsigned char uint8_t;
typedef struct {
uint8_t status;
}s_t;
int main() {
//原始方式
struct struct_t s = { 1 };
//定义了typedef使用方式
uint8_t status = 1;
s_t t;
t.status = status;
printf("%d\r\n", t.status);
return 0;
}