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...

Recommended Answers

All 2 Replies

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.

***sorry***

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.