From void back to main (How)?

Hello

I've got an a pretty annoying problem.
I have one main function, and a lot of void functions. Those void functions are called from the main.
But how can I get back to the main? How can I call the main function?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void functionA() {
//Code
}
void functionB() {
//Code
}
void functionC() {
//Code
}

int main() {
//Main Code
//More code
if (...) {
functionA();
} else if (...) {
functionB();
} else {
functionC();
}
//Code
}

Is pretty much my code.
How can I do this (And without using labels).

Thanks for reading,
Niely
Code control always goes back to the point after calling the function when the function ends. You don't need to do anything special to achieve what you want.
Last edited on
The program just exists when done.
I putted main();
In those if/else, so after the execution it just goes back to the main function.

Isn't there a way to let the code go to a specific point, like a label but more acceptable?
Oh, maybe you want to use a looping structure?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int main()
{
    //
    while(condition)
    {
        //
        if(condition)
        {
            functionA();
        }
        else if(condition)
        {
            functionB();
        }
        else
        {
            functionC();
        }
        //
    }
    //
}
Last edited on
How would I use that exactly? :)
I don't get it.
Is there really no possibility to do this without a label? o_O
I only want something like a label, that goes to a specific place in the code.
But because 'for some reason' labels aren't accepted I need another way for this.
Last edited on
The purpose of the loop in main() is to prevent the program from simply ending after calling one of the other functions. That should solve the biggest part of the problem you have.

By the way, you cannot simply call main() as though it was an ordinary function. That is not permitted by the C++ standard.
How would I use that exactly?

If you don't understand LB's while loop, then you need to read up on control statements.
http://www.cplusplus.com/doc/tutorial/control/

Is there really no possibility to do this without a label

Labels are used with gotos, but gotos are a bad practice.
Indeed! While loops are the solution!
:D

This is what I did:
1
2
3
4
bool back = true;
while (back) {
//All if/else statements
}


Thanks all!
Topic archived. No new replies allowed.