![]()
1 # 运算符
# 运算符是C/C++中的字符串化运算符,用于将记号(token)字符串化,示例如下:
#define PRINT(a, b) printf(#a " and " #b "\n")
int main(void)
{
PRINT(Dog, Cat);
system("pause");
return 0;
}
程序输出结果为:
Dog and Cat
2 ## 运算符
## 运算符是C/C++中的记号粘贴运算符,用于将两个记号粘连为一个记号,通常称为预处理器粘合剂。其示例如下:
#include <stdio.h>
#define cat(a, b) a##b
int main(void)
{
int abcd = 100;
printf("%d\n",cat(ab, cd));
return 0;
}
程序输出结果为:
100