integer input help
hello!!
i have a doubt about getting an integer input from the console
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include<iostream>
using namespace std;
int main()
{
int in;
while(1)
{
cout << "input: ";
cin >> in;
if(!(6>=in&&0<=in))
{
cout << "invalid input number\n";
continue;
}
else break;
}
}
|
in this program if i type the any characters like a or b etc.. the it becomes an infinite loop how do i avoid that....
http://cplusplus.com/forum/articles/6046/
Topic archived. No new replies allowed.