Jump to content
  • Advertisement
Sign in to follow this  
Xsis

Void?

This topic is 4445 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

Hi! i'm trying to make a small call program. but I've been looking at other programs. so like. int main() { Void lomme(); some program here cin.get() lomme(); } shouldn't that go back to it? or call the program once again?

Share this post


Link to post
Share on other sites
Advertisement
Xsis - again, not really sure what you mean but...

You can't declare a function inside another function.

void Lomme()
{
...
}

int main()
{
Lomme();
}

will call Lomme once from main.

Share this post


Link to post
Share on other sites
I think what he's looking for is labels and jumps, AKA the infamous goto directive.

Xsis - don't. Instead, put it in a loop, like so:

int main()
{
// alive is now set to true, we can see this for the duration of main
// because we have the scope to do so
bool alive = true;

// this will continue to loop (that is, when it gets to the "end" part of
// the while scope (the curly brackets), it will go back up to the top.
// It will keep doing this until we set alive to false. that is because
// the while loop will keep looping while the expression (inside the
// parenthesis, the brackets) validates to true. Since alive equals true, it
// validates to true instantly.
while (alive)
{
// do your own thing
cin.get();

// I made the variable up, but you get the idea - if we want to finish
// looping for some reason, we set the "flag" (the variable) alive to
// false. and voila, we're out of the loop
if (we_are_finished_for_some_reason) alive = false;
}
}

Share this post


Link to post
Share on other sites
Thanks :-D helped alot!!!

Sorry for asking so much! but still, i'm not good at understanding! but still trying the best I can! I appreciate the help! Thanks you guys! :-D
both Examples helped me alot!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!