Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

dd

Name: Anonymous 2011-04-19 0:06

Can anyone help me? I need a exception handling function. the one i have is failing


int errorTrap(int MIN, int MAX, int number)
{
    while(!cin.good() ||  number > MAX || number < MIN )
    {
       
        if ( !cin.good() )                 
        {
            cout << "Error" << endl;
            cin.clear ();
            cin.ignore( 128, '\n' );  
        }
        cout << "Enter a value:";
        cin >> number;
        
        if (number < MIN || number > MAX)
        cout << "invalid entry\n";
    }
    return number;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List