做什么#和##运营商使用C呢? [英] What do # and ## operators do in C?

查看:76
本文介绍了做什么#和##运营商使用C呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像#NAME或##名。他们怎么用C是什么意思?我看见他们在有关宏GCC文件。

something like #NAME or ##NAME. what do they mean in C? I saw them in GCC documents about macro.

推荐答案

##运营商连接两个参数让他们之间没有空格。

operator ## concatenates two arguments leaving no blank spaces between them..

 #define printe(a,b) a ## b
   printe(c,out) << "testing";

输出是:测试

和单#用于替换参数的枝条字符串参数

and single # is used for parameter replacement withe the string parameter like

#define  st(x)  #x
 cout<<st(tesing); //  equivalent to  cout<<"testing";

和#也是preprocessor指令。

and # is also a preprocessor directive..

这篇关于做什么#和##运营商使用C呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆