首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

Formal parameters 是形式参数的意义吗

2013-01-11 
Formal parameters 是形式参数的意思吗?Formal parameters are not replaced within quoted strings. If,

Formal parameters 是形式参数的意思吗?
Formal parameters are not replaced within quoted strings. If, however, a parameter name is preceded by a # in the replacement text, the combination will be expanded into a quoted string with the parameter replaced by the actual argument. This can be combined with string concatenation to make, for example, a debugging print macro:
#define dprint(expr) printf(#expr " = %g\n", expr)
When this is invoked, as in
dprint(x/y)
the macro is expanded into
printf("x/y" " = x/y);
and the strings are concatenated, so the effect is
printf("x/y = x/y);
Within the actual argument, each " is replaced by " and each \ by \\, so the result is a legal string constant.

上面内容,Formal parameters 是形式参数的意思吗?可是整段好像都没有形式参数的事啊。
还有,最后一段我也不理解。它说,每一个双引号都会被替换为",但是例子中没有被替换啊。
[解决办法]
就是形式参数的意思。
楼主后面关于双引号的问题是这个意思:


#define dprint(expr) printf(#expr " = %g\n", expr)

int main(int argc, char *argv[])
{
double d;
dprint(d);
dprint("d");
return 0;
}

gcc -E 的输出如下:(注意11行)

# 1 "fp.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "fp.c"


int main(int argc, char *argv[])
{
 double d;
 printf("d" " = %g\n", d);
 printf(""d"" " = %g\n", "d");
 return 0;
}

[解决办法]
是形式参数的意思,参数的前面加上#则会以参数加引号的方式展开。

热点排行