Setting limit on cin

I want to set limit on cin for example
1
2
3
int i;
cout<<"Please enter 4 digits id: ";
cin>>i

If user enter more then 4 digits it must give an error
I understand what your saying but can be a little more specific with what you want your code to accomplish and what task you want it to take?
Last edited on
You could check if i is less than 10000.
And larger than -10000.
@Bourgond Aries
Why would there be a negative ID? Wouldn't the range be from 0000 to 9999?
@peter87 i'll try thanks i
Topic archived. No new replies allowed.