Lets say i have a simple program like this:
If you compile and run this code, you will notice that after either case has been executed, the program will exit.Code:#include <iostream> using namespace std; void displaytext(); void displaynumbers(); int input; int main() { cout<<"What do you want to do?\n\n"; cout<<"1. Display Text.\n\n"; cout<<"2. Display Numbers\n\n"; cout<<"3. Exit.\n\n"; cout<<"Selection:"; cin>> input; switch ( input ) { case 1: cout<<"Text!!!!!!\n"; cin.get(); case 2: cout<<"Numbers!!!!!!\n"; cin.get(); case 3: cout<<"Good bye!\n"; cin.get(); default: cout<<"Bad input! lets try that again.\n"; cin.get(); } cin.get(); }
Without looping around the whole thing, is there a way to return to the beginning of the
program after Case 1,2,3 or default have been executed. And start all over from the beginning without restarting the program?



LinkBack URL
About LinkBacks



