理解题——typdef define 区别

《c专家编程》

区别1:

#define peach int

usigned peach i;  /*正确*/

typedef int banana;

unsigned banana i; /*错误*/

区别2:

#define int_ptr int *

int_ptr chalk, cheese;

宏扩展后相当于int * chalk,cheese;

typedef  int * int_ptr;

int_ptr chalk, cheese;

则表示int *chalk,*cheese;

用typedef定义的类型能够保证声明中的变量为同一类型!

原文地址:https://www.cnblogs.com/helloweworld/p/2818649.html