Hello.
I have a small problem in my home assignment. A neverending loop occurs, if user enters everything but digits, when I expect him to enter only digits.
How do I allow only int type variables to be entered by user?
The value user enters is the index number of node in linked list, which is deleted afterwards. If uder enters a,c,d... a neverending loop occurs later, when program tries to delete th n-th element in the list.
Posting the whole program is not needed I believe. The part I provide should be enough.
Thanks.
int number1;
int number2=5;
do{
cout<<"Which element do you want to delete?";
cin>>number1;
}while(number1<1 || number1>number2);