I have a menu program that works by calling each menu page as a function. But if the user selects 'Back' and 'Next' repeatedly the call stack will continue to increase which means I believe the program could theoretically crash.
In this code and in my program once the next menu function is called I would like to delete the current function from the stack since I no longer need it. Is such a thing possible?
Here is some sample code:

```
void menu1()
{
    //Get user input
    if (input == 0) //Go to menu2
        menu2();
    else     //Invalid input try again
        menu1();
}
void menu2()
{
    //Get user input
    if (input == 0) //Do something
    else if (input == 1) //Go back
        menu1();
    else        //Invalid input try again
        menu2();
}

```

As can be seen if the user inputs '0, 1, 0, 1...' then the stack keeps on growing.