大家都知道##这两个的意思是什么吧?见下:
其实就是连接的作用,例如:a##1 的结果就是a1,这是简单的用法了,若只是如此的话并莫有什么意义的,但也不要小瞧它哟 在很多实际运用中还是有大用处的,如宏定义一个打印方法:
#include
#include
#define YYG_PRINT(fmt, arg...) printf(fmt, ##arg)
int
main()
{
int m = 20, n = 90, l = 80;
char str[16] = "amstr";
char ch = 'a';
YYG_PRINT("m is %d n is %d l is %d str is %s ch is %c\n", m, n, l, str, ch);
exit(0);
}
run result:
[root@UFO]# ./a.out
m is 20 n is 90 l is 80 str is amstr ch is a