typedef的作用:起别名,方便
方法:typedef 数据类型 别名;
typedef int U8; //int =U8,意思就是,以后用U8来代替int的使用
平常声明一个变量一般是:int x -> U8 x =======这两者是等价的
int main(int argc ,char *argv[ ] )
{
U8 a; //int a;
}
**typedef 结构体**
typedef struct book BOOK; =====BOOK是这个结构体struct book的别名,这时还没有声明结构体变量哦,别搞混,我之前就是搞混这里导致看不懂
我们一般是用这样方式定义别名的
typedef struct book
{
int pricel
char type;
}BOOK;
这里的BOOK就是struct book这个结构体的别名
BOOK book1; 这才是声明结构体变量,注意区分!
同时,**BOOK book1 = struct book book1**