I have the following code
Code:
cout<<"What is the hour of the activity (Standard hour 1-24)?";
cin>>hour;
while(!(cin>>hour) || hour<0 || hour>24 )
{
cout<<"\nThe hour entered is not valid. Please try again: ";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
}
I need the user to enter an hour between 1 and 24 and make sure that the data enter is an integer, now I'm able to do this but when the user enter the time for the first time it doesn't want to read it unless is not a number , they have to press enter and enter it one more time for the program to read it. I'm using Microsoft Visual Studio 2005. Thanks