c语言之宏定义中的##和#
1.##:用于拼接操作
实例:
#include<stdio.h> #include<iostream> #define CONCAT(parm1,parm2) (parm1##parm2) int main() { int res = CONCAT(1, 2); printf("%d\n", res); char* ptr = CONCAT("nihao!","zaijian"); printf("%s\n", ptr); system("pause"); return 0; }
2.#:用于将参数进行字符串化
#include<stdio.h> #include<iostream> #include<typeinfo> #define TO_STRING(parm) #parm int main() { char* ptr = TO_STRING(110); printf("%s\n",typeid(ptr).name()); system("pause"); return 0; }
相关推荐
choupiaoyi 2020-04-19
zuixin 2020-02-22
lvbin0 2012-07-03
Will0 2011-03-15
fengjing81 2019-11-07
liangds 2011-10-03
ericasadun 2012-01-04
wwater 2011-11-20
liangds 2012-06-03
mojianc 2019-06-27
87214551 2013-06-13
小南地带 2019-06-21
tubiebutu 2019-06-21
tubiebutu 2019-06-20
shi0 2011-09-29
fzhykx 2018-08-16
caiyuxia0 2016-01-17