Q:

Switch statement reading every input in c++

I have this switch statement that is used to allow the user to select an option. It quits when the user enters 9. But the problem is that when I enter something like "ah2" it will read 'a' then print the error message, next 'h' and the error message and then the 2. The program is supposed to stop when the user enters such input and should ask to enter a different input.
Here is my code.
void menu()
{

    int choice = 0;

    cout<<"\nWelcome to the program menu."<<endl;
    cout<<"Choose the operation you would like to execute."<<endl;
    cout<<"1. Create "<<endl;
    cout<<"2. Look items "<<endl;
    cout<<"3. See "<<endl;
    cout<<"4. Get "<<endl;
    cout<<"5. See the value "<<endl;
    cout<<"6. Insert an item"<<endl;
    cout<<"7. Delete an item"<<endl;
    cout<<"8. Destroy "<<endl;
    cout<<"9. Press -1 to exit the program"<<endl;

    cout<<"Enter your choice: "<<endl;
    cin>>choice;

   while(choice != 9)
    {
        switch (choice)
        {
case 1:
            cout<<"You choose one"<<endl;
            break;
        case 2:
            cout<<"You choose two"<<endl;
            break;
        case 3:
            cout<<"You choose three"<<endl;
            break;
        case 4:
            cout<<"You choose four"<<endl;
            break;
        case 5:
            cout<<"You choose five"<<endl;
            break;
        case 6:
            cout<<"You choose six"<<endl;
            break;
        case 7:
            cout<<"You choose seven"<<endl;
            break;
        case 8:
            cout<<"You choose height"<<endl;
            break;
        case 9:
            cout<<"You choose nine"<<endl;
            break;
        default:
            cout<<"You have not entered a number proposed. Retry. "<<endl;
            choice = 0;
            break;
        }
        cin.clear();
        cin.ignore();
        cout<<"Enter your choice : "<<endl;
        cin>>choice;
    }
    cout<<"\nYou have entered the exist option end the program"<<endl;
}

A:

change cin.ignore() to cin.ignore(INT_MAX, '\n')

