Number checker + make it positive

So I have this piece of code I've been using a lot:
1
2
3
4
5
6
    while(!(cin >> x))
	{
        cin.clear();
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
        cout << "Invalid input.  Try again: ";
    }


That checks to make sure x is a number and not say a letter or the # sign or something.

Now, for a new project, I need to modify this code to also check that the number is positive and falls within a particular range(say less than 1000, just as an example). I'm pretty sure I need to make a modification to the while statement but I am not exactly 100% sure how or what.

Thank you kindly.
Topic archived. No new replies allowed.