I need some help with cin.peek ();

Hi all:

:krazy:
I need some help with cin.peek ();

I have a menu system that will prompt the user enter a number
from 1 – 5, 5 = exit that menu.

The problem is when the user hits the enter key for a given menu
option. This is a problem for me I have tried several deferent approaches

to this with no success help please

Thank you,
Manny c++


 
int Menu::showMainMenu()
{
 
 
    bool valid;
    int _choice;
 
    do
    {
 
        cout << endl << endl;
        cout << "	Welcome " << P -> FullName() << "," << " to your Main menu.
";
        cout << "	Please Enter a menu option: 1, 2, 3, 4, or 5 to exit.
";
        cout << endl;
        cout << "	1) Movie Menu        2) Music Menu
";
        cout << "	3) alibi        4) comfort
";
        cout << "	5) quit
";
        cout << endl << endl;
 
        cout << "	Please enter Main Menu option: ";
 
        if ((_choice = cin.peek()) == '
') {cin.get();}
        cin >> _choice;
 
        cin.clear();
 
 
        if (_choice == '
')
        {
            cin.clear();
            cin.ignore(100, '
');
 
            printf("
	\a%c[%d;%dmThat's not a good choice ", 0x1B, BRIGHT, RED, BG_BLACK);
            printf("%c[%dm", 0x1B, 0);
            cout << P -> FullName();
            printf(", %c[%d;%dmtry agin Manddy.
", 0x1B, BRIGHT, RED, BG_BLACK);
            printf("%c[%dm", 0x1B, 0); 
 
            cout << "	Please Reenter your Main Menu Option Manny: ";
            cin >> _choice;
 
 
        } 
 
 
 
        valid = false;
 
        if (isalpha(_choice)) { valid = true; }
 
        if (valid == true)
        {
 
            cin.clear();
            cin.ignore(100, '
');
 
            printf("
	\a%c[%d;%dmYou entered a letter ", 0x1B, BRIGHT, RED, BG_BLACK);
            printf("%c[%dm", 0x1B, 0);
            cout << P -> FullName();
            printf(", %c[%d;%dmPlease Enter a number from (1 - 4).

", 0x1B, BRIGHT, RED, BG_BLACK);
            printf("%c[%dm", 0x1B, 0);
 
            cout << "	Please Reenter your Main Menu option: ";
            cin >> _choice; 
 
        } 
 
        switch (_choice)
        {
 
            case 1 : showMovieMenu();
                 break;
            case 2 : music();
                 break;
            case 3 : cout << "	The boss was in all day.";
                 break;
            case 4 : comfort();
                 break;
            case 5 : break;
 
            default :
                 printf("
	\a%c[%d;%dmThat's not a good choice ", 0x1B, BRIGHT, RED, BG_BLACK);
                 printf("%c[%dm", 0x1B, 0);
                 cout << P -> FullName();
                 printf(", %c[%d;%dmtry agin.
", 0x1B, BRIGHT, RED, BG_BLACK);
                 printf("%c[%dm", 0x1B, 0);
 
        }
 
 
    }
    while (_choice != 5);
 
    cout << endl << endl;
    cout << "	Thank you " << P -> FullName() << ", " << "for using Samsungs,
";
    cout << "	move and music tool.


";
 
 
    /** To remove the newLine on reEntering 
     *  the mainMenu system               */
 
//    cin.clear();
//    cin.ignore(100, '
');
 
    return 0;
 
}