Number Guessing game

I am writing a program where you pick a number between 1 and 100. In this program i choose what the winning number is. I have it working when the user enters a number but when they enter a letter it crashes how do i fix this thanks
1
2
3
4
5
6
7
int number ;
while( !( std::cout << "please enter a number: " && std::cin >> std::ws >> number ) )
{
     std::cin.clear() ;
     std::cin.ignore( 1000, '\n' ) ;
}
// use number 

Thank you very much
I guess that jham92 and kyky365 are in the same class? Both asked about the same topic around the same time.
Topic archived. No new replies allowed.