c语言定义宏 #define call(x,y) x##y表示什么?

程序如下:
#define call(x,y) x##y
int main()
{ int x=5,y=10,xy=20;
printf("%d\n",xy+call(x,y));
return 0;
}
结果为40
请问 x##y表示的是什么运算

c语言中,##表示把两个宏参数贴合在一起,即,
#define call(x,y) x##y ,执行call(x,y)结果为xy,例如,
int x=2,y=5;
int xy=90;
printf("%d\n",call(x,y));//结果为90

##被称为连接符,用来将两个宏参数连接为一个宏参数。
而单个#的功能是将其后面的宏参数进行字符串化操作,简单地说就是在对它所引用的宏变量通过替换后在其左右各加上一个双引号,使其成为字符串。
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-01
#define call(x,y) x##y

##把x和y连接起来,相当于新变量xy

xy+call(x,y) 就相当于xy+xy=20+20=40;

参考资料:
The preprocessor operator ## provides a way to concatenate actual arguments during macro
expansion. If a parameter in the replacement text is adjacent to a ##, the parameter is replaced
by the actual argument, the ## and surrounding white space are removed, and the result is rescanned.
For example, the macro paste concatenates its two arguments:
#define paste(front, back) front ## back
so paste(name, 1) creates the token name1.本回答被提问者采纳
第2个回答  2010-09-20
## 连接符号由两个井号组成,其功能是在带参数的宏定义中将两个子串(token)联接起来,从而形成一个新的子串。

call(x,y) 的意思就是 xy
即 xy+call(x,y) = xy+xy = 20 + 20 = 40
第3个回答  2010-09-20
从未听说过
相似回答