# :1、最常见的是 #不会替换参数,只替换其所对应的字符
2、 把宏参数变成一个字符串;
## :把两个宏参数连接到一起(只能两个)
#include <stdio.h>
#include <stdlib.h>
#define ONE 1 //1.最常见的是 #不会替换参数,只替换其所对应的字符;
#define toString(str) #str //2.转字符串
#define hehe(x,y) x##y //连接
int main()
{
printf("%d\n",ONE); //#不会替换参数,只替换其所对应的字符;
printf(toString(123456)); //输出字符串"123456"
printf("\n %d \n",hehe(1,2)); //输出 int 12
char string[]="hello world!";
printf("%s\n",hehe(str,ing));
system("pause");
return 0;
}
输出结果
1
123456
12
hello world!