理解题——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定义的类型能够保证声明中的变量为同一类型!

posted @ 2012-12-14 20:44  helloweworld  阅读(178)  评论(0编辑  收藏  举报