##号的用途及linux c测试代码

大家都知道##这两个的意思是什么吧?可见: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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值