关于宏定义
宏定义中#和##的使用.
#的功能是将#后面的参数进行字符串化操作
#include <stdio.h>
#define P(func1, func2) { \
printf("%s = %d\n", #func1, func2); \
}
int main() {
P(haha, 4);
return 0;
}
/*
运行结果:
haha = 4
*/
##是字符串链接符
#include <stdio.h>
#define P(n) { \
printf("%d\n", a##n);\
}
int main() {
int a1 = 3;
int a2 = 4;
P(1);
P(2);
return 0;
}
/*
运行结果:
3
4
*/