大家都知道##这两个的意思是什么吧?可见:http://blog.csdn.net/yygydjkthh/article/details/4422945
其实就是连接的作用,例如:a##1 的结果就是a1,这是简单的用法了,若只是如此的话并莫有什么意义的,但也不要小瞧它哟 在很多实际运用中还是有大用处的,如宏定义一个打印方法:
/*********************************************************************
* Function: Test double '#' character connection
* Author : Samson
* Date : 11/23/2011
* Test platform:
* GNU Linux version 2.6.29.4
* gcc version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC)
* *******************************************************************/
#include <stdio.h>
#include <stdlib.h>
#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