宏中的# ##作用

来源:互联网 发布:多益网络徐波 编辑:程序博客网 时间:2024/05/19 22:51

使用#把宏参数变为一个字符串,用##把两个宏参数贴合在一起

#include <stdio.h>#define STR(S) #S#define CON(A,B) (A##B)int main(void){    printf("%s\n",STR(hello));    printf("%x\n",CON(0x,FF));    return 0;}

输出结果为:

hello
ff

原创粉丝点击