The Ctrl-D worked. I have the same problem. It just starts looping endlessly. The only way I was able to fix it was to add a cin.clear() and cin.seekg() in function GetChoice.
Code:
void GetChoice(int& choice)
{
char temp[10];
cout<<"The following is the menu."<<endl;
cout<<"A code is provided for a respective operation."<<endl;
cout<<"PLEASE NOTE: You must LOAD the array to enter another "<<endl;
cout<<"data list."<<endl;
cout<<endl;
cout<<"1 --------------- LOAD the array"<<endl;
cout<<"2 --------------- DISPLAY the array"<<endl;
cout<<"3 --------------- SORT the array (ascending)"<<endl;
cout<<"4 --------------- AVERAGE the array"<<endl;
cout<<"5 --------------- LARGEST number display"<<endl;
cout<<"6 --------------- SMALLEST number display"<<endl;
cout<<"7 --------------- SEARCH the display for a number"<<endl;
cout<<"8 --------------- BETWEEN two numbers display existing numbers"<<endl;
cout<<"9 --------------- INSERT a number into array"<<endl;
cout<<"10 --------------- DELETE a number in the array"<<endl;
cout<<"13 --------------- QUIT"<<endl;
cout<<endl;
cout<<"Enter your choice"<<endl;
cin.clear();
cin.seekg(0);
if (cin.good())
cout << "GOOD." << endl;
//cin.getline(temp,10);
//choice = atoi(temp);
cin >> choice;
cout<<choice<<endl;
}
Also, I saw another problem. You need some brackets here:
cout<<"Enter all data at once,leaving spaces in between, then press Enter, Ctrl+D, Enter"<< endl;
while (cin)
{//HERE
cin>>list[counter];
counter++;
}//HERE