没有表情就回来了 [英] Return with no expression

查看:66
本文介绍了没有表情就回来了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题刚出现在我的脑海里,那是什么?

a''返回''没有表情和''休息''或''退出()'之间的区别'?提前完成

为你的方向。

解决方案

sugaray< ru **** @ sohu.com>潦草地写了下面的内容:

这个问题让我想起了没有表达和休息之间的区别是什么? ''出口()'' ?提前完成
你的方向。




差别很大。

" return"从当前函数返回。如果当前函数是main()的原始调用,则程序结束。否则

控制流将返回到当前函数的任何一个函数。

break从当前循环返回(for,while或do ... while)。如果

循环是函数体的最后一个语句,或者在它之后有一个return

,则该函数返回(参见return)。否则它继续为

正常。

" exit()"结束程序,然后。无论从哪个函数调用它,以及它被埋入多少循环,它总是结束

整个程序。

可能我建议你读一本C教科书?


-

/ - Joona Palaste(pa*****@cc.helsinki.fi) - ------------芬兰-------- \

\-- http://www.helsinki.fi/~palaste -------------------- - 规则! -------- /

这是一个人员通勤者。

- 科学美国人的火车司机


>>这个问题刚刚出现在我的脑海中,那就是blockquote class =post_quotes>

在没有表达的''return'和'break'之间的区别是什么? ''退出()''?
提前为你指示。



" break"从当前循环返回(for,while或do ... while)。如果循环是函数体的最后一个语句,或者有一个
return,那么它就是函数体的最后一个语句。之后,函数返回(参见return)。否则它继续正常。




当然它也用在switch语句中,这是一个至关重要的

元素。


IIRC C ++也允许这样做:


int somefunction(void)

{

int i;


{

int j;


//在这里做点什么

如果(j)

休息;


//在这里做点什么

} < br $>
}


但我不是这个主题的权威。


-

Martijn
http://www.sereneconcepts.nl





sugaray写道:


这个问题让我想起了什么''
a''return''没有表情和''break''或''exit()''之间的区别?提前完成
你的方向。




''return''没有表达式从一个函数转移控制(其中

返回类型为void)到调用函数。它在具有非null返回类型的

函数中无效。


''break''将控制转移出switch语句或执行循环。


''退出()''不合法。 exit函数需要一个int参数。这是
终止该计划。


-

Fred L. Kleinschmidt

波音助理技术研究员

技术架构师,通用用户界面服务

M / S 2R-94(206)544-5225


hi, this question just came up my mind that what''s the difference between
a ''return'' with no expression and a ''break'' or ''exit()'' ? thanx in advance
for your direction.

解决方案

sugaray <ru****@sohu.com> scribbled the following:

hi, this question just came up my mind that what''s the difference between
a ''return'' with no expression and a ''break'' or ''exit()'' ? thanx in advance
for your direction.



Quite a big difference.
"return" returns from the current function. If the current function is
the original invocation of main(), the program ends. Otherwise flow of
control returns to whichever function called the current function.
"break" returns from the current loop (for, while or do...while). If the
loop is the last statement of the function body, or there is a "return"
after it, the function returns (see "return"). Otherwise it continues as
normal.
"exit()" ends the program, there and then. No matter from which function
it was called, and how many loops it is buried in, it always ends the
entire program.
Might I suggest you read a C textbook?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"This is a personnel commuter."
- Train driver in Scientific American


>> hi, this question just came up my mind that what''s the difference

between a ''return'' with no expression and a ''break'' or ''exit()'' ?
thanx in advance for your direction.



"break" returns from the current loop (for, while or do...while). If
the loop is the last statement of the function body, or there is a
"return" after it, the function returns (see "return"). Otherwise it
continues as normal.



And of course it is used in switch statements as well, where it is a crucial
element.

IIRC C++ would allow this too:

int somefunction(void)
{
int i;

{
int j;

// do something here
if ( j )
break;

// do something else here
}
}

But I am no authority on the subject.

--
Martijn
http://www.sereneconcepts.nl




sugaray wrote:


hi, this question just came up my mind that what''s the difference between
a ''return'' with no expression and a ''break'' or ''exit()'' ? thanx in advance
for your direction.



''return'' with no expression transfers control from a function (whose
return type is void) to the calling function. It is not valid in a
function with a non-null return type.

''break'' transfers control out of a switch statement or do loop.

''exit()'' is not legal. The exit function requires an int argument. It
terminates the program.

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225


这篇关于没有表情就回来了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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