C++ press enter to continue

Unless you wrap your entire menu code inside a loop and make the exit condition for this loop the user input(in your case typing 5 for exit) the program will terminate as soon as it returns from your seatingchart() function because the list() function will return to main(i.e seatingchart() returns to list() and list() will return to main() ). You should do something like this:

do
{
   cout << "\n\n\n\t\tC++ Theatre" << endl << endl;
   cout << "\n\t1.  View Available Seats";
   cout << "\n\t2.  View Seating Prices";
   cout << "\n\t3.  View Ticket Sales";
   cout << "\n\t4.  Purchase a Ticket";
   cout << "\n\t5.  Exit the Program\n\n";
   cout << "\n\tEnter your choice(1-5):  ";
   cin>>choice;

   while(choice>5 || choice<1)
   {
      cout<<"Choice must be between 1 and 5. Please re-enter:";
      cin>>choice;
   }

   if (choice == 1)
      seatingChart();
   else if (choice == 2)
      getPrices();
   else if (choice == 3)
      viewSales();
   else if (choice == 4)
       ticketSales();
   else if (choice==5)//this is your exit condition
        break;//will break out of the menu loop
}while(1);//the is your menu loop

By the way there are some logical errors in your code, see the comment that are given in the comment section and correct them.

Leave a Comment