Basically this Menu works however, when I enter in a string the default does catch it but then the Menu repeats the error so in essence isnt full proof. Would the way around this be to check the 1st entry by the user to see if its an integer, if so progress to the do while if not give an initial error message till they enter an integer? Or is there a wiser way around this annoying flaw? Thanks.
do { // Do While Loop that incorporates Menu and List Functions
system("cls"); //clears previous entries & redisplays the Menu per selection
// Displays Menu Screen for user interaction of List
cout << "**********Menu*************"<< endl;
cout << "* 1. Populate List *"<< endl;
cout << "* 2. Sort list *"<< endl;
cout << "* 3. Search List *"<< endl;
cout << "* 4. Display List *"<< endl;
cout << "* 0. Exit *"<< endl;
cout << "***************************"<< endl;
cout << " "<< endl;
cout << "Please select your option "<< endl;
cin >> n;
cout << " "<< endl;
switch (n)
{
case 1 :
disp.populate();
cout << "List populated."<< endl;
system("Pause");
break;
case 2 :
disp.sort();
system("Pause");
break;
case 3 :
cout << "Please enter the value you wish to search from the List"<< endl;
cin >> p;
system("Pause");
break;
case 4 :
disp.toString();
system("Pause");
break;
default:
if (n !=0)
{
cout << "Enter a number relating to the Options shown!!!" << endl;
system("Pause");
}
break;
}
}
while (n != 0); // Exit Condition
system("Pause");