什么价值缺乏回报或空的“回报”;返回 [英] what value does lack of return or empty "return;" return

查看:81
本文介绍了什么价值缺乏回报或空的“回报”;返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当一个函数没有指定一个返回类型时,值是什么值

返回。在下面的程序中,函数sample()返回传递给''k'的

值。


sample(int);

main()

{

int i = 0,j;

j = sample(0);

printf("%d",j);

getch();

}


sample( k)

{

返回;

}

Hi,
when a function doesn''t specify a return type ,value what value is
returned. In the below programme, the function sample()is returning the
value passed to ''k''.

sample(int);
main()
{
int i = 0,j;
j = sample(0);
printf("%d", j);
getch();
}

sample(k)
{
return;
}

推荐答案

Greenhorn写道:
Greenhorn wrote:

当一个函数没有指定一个返回类型时,返回值返回的值。在下面的程序中,函数sample()返回传递给''k'的
值。

sample(int);
main()
{
int i = 0,j;
j = sample(0);
printf("%d",j);
没有声明? (提示:你包括什么?)getch();
没有这样的事情。 }

示例(k)
{
返回;
}
Hi,
when a function doesn''t specify a return type ,value what value is
returned. In the below programme, the function sample()is returning the
value passed to ''k''.

sample(int);
main()
{
int i = 0,j;
j = sample(0);
printf("%d", j); No declaration? (Hint: what are you including?) getch(); No such thing. }

sample(k)
{
return;
}



这是未定义的行为。可能是什么。或者鼻子恶魔可能随之发生。

(唯一的例外是`main()''在C99中返回0如果没有值明确返回
。你不是使用C99;你的程序因为试图使用隐式int而被拒绝了。)


调高编译器的警告级别!


HTH,

- $

-

Artie Gold - 德克萨斯州奥斯汀
http://it-matters.blogspot.com (新帖子12/5)
http://www.cafepress.com/goldsays


It''s undefined behavior. Could be anything. Or nasal demons might ensue.
(The only exception is that `main()'' returns 0 in C99 if no value is
explicitly returned. You''re not using C99; your program would have been
rejected for trying to use implicit int.)

Turn up the warning level on your compiler!

HTH,
--ag
--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays


在消息< 38 ************* @ individual.net>

Artie Gold< ar ** *****@austin.rr.com>写道:
In message <38*************@individual.net>
Artie Gold <ar*******@austin.rr.com> wrote:
Greenhorn写道:
Greenhorn wrote:
sample(k)
{
return;
}
sample(k)
{
return;
}

<这是未定义的行为。可能是什么。或者鼻子恶魔可能随之发生。
(唯一的例外是如果没有明确返回值,那么`main()''在C99中返回0。你没有使用C99;你的程序本来就是
因试图使用隐式int而被拒绝。)


It''s undefined behavior. Could be anything. Or nasal demons might ensue.
(The only exception is that `main()'' returns 0 in C99 if no value is
explicitly returned. You''re not using C99; your program would have been
rejected for trying to use implicit int.)




它也会因为该返回而被拒绝 - 返回没有值

其中一个是必需的,现在是C99中的约束违规。


-

Kevin Bracey,首席软件工程师

Tematic Ltd电话:+44(0)1223 503464

182-190 Newmarket Road传真:+44(0)1728 727430

剑桥,CB5 8HE,英国WWW: http://www.tematic.com/


Kevin Bracey写道:
Kevin Bracey wrote:
在消息< 38 ************* @ individual.net>
Artie Gold< ar ******* @ austin.rr.com>写道:

In message <38*************@individual.net>
Artie Gold <ar*******@austin.rr.com> wrote:

Greenhorn写道:
Greenhorn wrote:
示例(k)
{
返回;
}
sample(k)
{
return;
}



这是未定义的行为。可能是什么。或者鼻子恶魔可能随之发生。
(唯一的例外是如果没有明确返回值,那么`main()''在C99中返回0。你没有使用C99;你的程序本来就是
因试图使用隐式int而被拒绝。)



It''s undefined behavior. Could be anything. Or nasal demons might ensue.
(The only exception is that `main()'' returns 0 in C99 if no value is
explicitly returned. You''re not using C99; your program would have been
rejected for trying to use implicit int.)



对于该返回也会被拒绝 - 返回没有值
其中一个是必需的,现在是C99中的约束违规。


It would also have been rejected for that return - a "return" without a value
where one is required is now a constraint violation in C99.



它会走得那么远吗?在我看来它甚至不会解析。


- g


-

Artie Gold - 德克萨斯州奥斯汀
http://it-matters.blogspot.com (新帖子12/5)
http://www.cafepress.com / goldsays


Would it have gotten that far? Seems to me it wouldn''t even parse.

--ag

--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays


这篇关于什么价值缺乏回报或空的“回报”;返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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