Sign in to follow this  
Xsis

Void?

Recommended Posts

Xsis    100
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
Aardvajk    13207
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
_goat    804
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
Xsis    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this