例子:
#define pi 3.14
#define s(x) #x
#define S(x) s(x)
cout<<S(pi);输出3.14,即输出"9"这个字符串
cout<<s(pi);输出3.14,即输出"d"这个字符串
首先我们必须要明白,“#define s(x) #x”中第二个#号表示,把宏变量x表示的内容作字符串处理,至于宏变量x表示的内容是什么,不再处理。
例子:
#define pi 3.14
#define s(x) #x
#define S(x) s(x)
cout<<S(pi);输出3.14,即输出"9"这个字符串
cout<<s(pi);输出3.14,即输出"d"这个字符串
首先我们必须要明白,“#define s(x) #x”中第二个#号表示,把宏变量x表示的内容作字符串处理,至于宏变量x表示的内容是什么,不再处理。