Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Drakon

Returns

This topic is 6028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Guest Anonymous Poster
They also return a result for non-void functions.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include
#include

bool do_stuff(string name)
{
if(name == "Alex")
return true;
else
return false;
}

void main(void)
{
char tmp[50];
cout<<"Enter your name:\n";
cin.get(tmp,50);

if(do_stuff(tmp))
cout<<"Your cool!\n";
else
cout<<"You Suck!!!!";
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include
#include

bool do_stuff(string name)
{
if(name == "Alex")
return true;
else
return false;
}

void main(void)
{
char tmp[50];
cout<<"Enter your name:\n";
cin.get(tmp,50);

if(do_stuff(tmp))
cout<<"Your cool!\n";
else
cout<<"You Suck!!!!";
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oops, didn''t mean to post it twice!

Share this post


Link to post
Share on other sites
Here''s an example:

  
int main()
{

int x = decideX();

}

int decideX()
{

return 3;

}


Main calls on decideX, which returns 3. 3, being the result of decideX, is assigned to the int variable x. Control is returned to main().

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!