Re: diffrence between return and return 0
Joseph Hadzima <[email protected]> Thu, 22 Feb 2007 08:08:02 -0800 (PST)
| Newsgroups | gmane.comp.programming.cppug |
|---|---|
| Message-ID | <[email protected]> |
return; // just return control to the calling function
// used by VOID functions.
return 0; // return to the calling function and put the
// value 0 on the stack.
// silly example:
void foo( int x )
{
if( x == 2 )
{
cout << "I got a two" << endl;
return;
}
cout << " I wanted a two, but got a " << x << endl;
}
int foofoo( int x )
{
if( x == 2 )
{
return 0;
}else{
return 1;
}
}
int main()
{
int a = 3;
int b = foofoo( a ); // foofoo() RETURNS A value!
// b gets the value returned on the stack
if( b != 0 )
{
cout << "foofoo was NOT two" << endl;
}
foo( a ); // display message, does NOT return value
}
--- ranjane_s <[email protected]> wrote:
>
> Hi all,
> can anyone please explain me the difference between
> return and return 0
>
> thanks in advance..
> urs,
> Ranjane.R
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Something is new at Yahoo! Groups. Check out the enhanced email design.
http://us.click.yahoo.com/kOt0.A/gOaOAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups - Join or create groups, clubs, forums & communities. Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/cppug/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/cppug/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups - Join or create groups, clubs, forums & communities. is subject to:
http://docs.yahoo.com/info/terms/