0

Hello I'm having a stuggling implmenting some code...here's what I've got so far:

cout << "\n\nChoice" << endl;
       cin >> choice;
	
while (choice!=0)
   {
    switch(choice)
    {
    case 1:
        cout << "Inserting manually..." << endl;
                        //  addmanual();
       break;

case 2:
      cout << "Inserting from file... "<< endl;
                 cout << "file completion....";			break;

case 3:
     cout << "Calling delete function..." << endl;
                 // call function delete employee
            break;

case 4:
    {
     int change = 0;
     cin >> change;
    while(change != -1)
	{					switch(change)
                 {
	case 1:
                    {						       cout << "hello world" << endl;			       break;
                    }
	case 2:
                   {						       cout << "111" << endl;				       break;
                   }
             case 3: 
                   {						       cout << "000" << endl;				       break;
                   }

					
//default: cerr << "error in choice" <<endl;
}}
				
//	default: cerr << "error in choice" <<endl;
                  
					
 }}

The problem is how do I terminate the 2nd switch allowing the user to return to the first menu?

Cheers...

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by SpS
0

move the cin >> change inside the while statement. Add a case -1 to the switch statement. If switch conditional switch conditionals must be a positive integer then check the value of change outside the switch statement in an if statement such that if change == -1 don't check the switch statement, else do check the switch statement.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.