View Single Post
  #2 (permalink)  
Old 04-24-2008, 11:45 AM
R-G's Avatar   
R-G R-G is offline
Programmer
 
Join Date: Apr 2007
Location: Europe
Posts: 144
Credits: 0
Rep Power: 0
R-G is an unknown quantity at this point
Post

I think, with an similar example of a source software code algorithm, written in the computer programming language C++ you will understand it better.

Code:
while (!Valid)
    {
        cout << "Enter a number string: ";
        cin >> Number;
        if (cin)
        {
            cin.ignore(numeric_limits<int>::max(), '\n');
            if (cin.gcount() == +1)
            {
                if ( Number >= 0)
                {
                    Valid = true;
                }
            }
        }
        else
        {
            cin.clear();
            cin.ignore(numeric_limits<int>::max(), '\n');
            cout << "Not a valid number string. Try again: \n";
        }
    }
__________________
Like an angel without a sense of mercy.
Reply With Quote