函数声明/默认值 [英] Function declarations/defaults
问题描述
在c中我可以声明一个函数参数的默认值吗?
int X(int a,int b = 10);
int main()
{
X(1);
}
int X(int a,int b)
{
printf(" a =''%d'',b =''%d''\ n" ,a,b);
}
___ _ ____ ___ __ __
/ _)(_)/ / _ __ / _ \ ___ _ / / _ / / ____ ___
/ _ / / / / // / / ___ / _` / __ / __ / _ \ / _ \
/ ____ / _ / _ / _ / \ _,/ / _ / \\ _ _,_ / \ __ / \ __ / \ ___ / _ // _ /
/ ___ /
德州仪器(TI)ASIC电路设计Methodlogy Group
达拉斯,得克萨斯州,214-480-4455, b - ****** @ ti.com
In c can I declare a default value for an function argument?
int X(int a,int b=10);
int main()
{
X(1);
}
int X(int a,int b)
{
printf("a = ''%d'' , b = ''%d''\n",a,b);
}
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, b-******@ti.com
推荐答案
Billy Patton写道:
Billy Patton wrote:
在c中我可以声明一个函数参数的默认值吗?
int X(int a,int b = 10);
int main()
{/> X(1);
}
int X(int a,int b)
{/> printf(" a =''% d'',b =''%d''\ n",a,b);
}
In c can I declare a default value for an function argument?
int X(int a,int b=10);
int main()
{
X(1);
}
int X(int a,int b)
{
printf("a = ''%d'' , b = ''%d''\n",a,b);
}
不在C中。
Not in C.
文章< Pi ***************************** **@bright.dal.desi gn.ti.com>,Billy Patton写道:
In article <Pi*******************************@bright.dal.desi gn.ti.com>, Billy Patton wrote:
在c中我可以声明一个函数参数的默认值吗?
In c can I declare a default value for an function argument?
不,与C ++中的方式不同。您可以通过数组或可变长度参数
列表粗略地模拟
它。
-
Andreas K?h?ri
No, not in the same way as in C++. You could possibly simulate
it in a crude way by means of arrays or variable length argument
lists.
--
Andreas K?h?ri
2003年11月14日星期五09:11:41 -0600,Billy Patton< bp *** **@bright.dal.design.ti.com>写道:
On Fri, 14 Nov 2003 09:11:41 -0600, Billy Patton <bp*****@bright.dal.design.ti.com> wrote:
printf(" a =''%d'',b =''%d''\ n",a,b);
}
___ _ ____ ___ __ __
/ _)(_)/ / _ __ / _ \ ___ _ / / _ / / ____ ___
/ _ / / / / // / / ___ / _` / __ / __ / _ \ / _ \
/ ____ / _ / _ / _ / \\ _,_ / _ / \ _,_ / \ __ / \ __ / \ ___ / _ // _ /
/ ___ /
德州仪器ASIC电路设计方法集团
达拉斯,得克萨斯州,214-480-4455, b - ****** @ ti.com
您发送垃圾邮件Usenet。
离开sig分隔符 - 如果他们愿意的话,人们可以不去查看
sigs。
这真的很黏糊糊。
并且sig是有限的
到分隔符下面的四行。
Killfiled 30天。
清理你的行为。
-
Alan C这篇文章的结尾是w
q
You are spamming the Usenet.
By leaving off the sig delimiter "-- " that allows people to not-view
sigs if they want to.
This is truly slimy.
And sigs are limited
to the four lines immediately below the delimiter.
Killfiled for 30 days.
Clean up your act.
--
Alan C this post ends with w
q
这篇关于函数声明/默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!