字符串化运算符#

#define SQR(x) printf("the squar of x is %d\n",((x)*(x)))

如果直接调用SQR(8),则输出the squar of x is 64

也就是“”中的字符x被当作普通字符来处理,没有被8替换掉

修改宏定义如下:

#define SQR(x) printf("the squar of “#x ”is %d\n",((x)*(x)))

再调用SQR(8),则输出the squar of 8 is 64

#的作用就是可以把语言符号转换为字符串

原文地址:https://www.cnblogs.com/qmlm8844/p/2782387.html