宏定义

来源:互联网 发布:php try catch 的用法 编辑:程序博客网 时间:2024/05/18 03:59
1.使用#把宏参数变为一个字符串。
#define STR(s) #s
printf(STR(xuyang))
xuyang

2.使用##把宏参数连接
#define CONS(a,b) (int)(a##e##b)
printf("%d \n", CONS(2,3));
2e3 ->2000

3.宏定义求数组个数
#define ARR_SIZE(a) ((sizeof(a))/(sizeof(a[0]))

原创粉丝点击