its my first day of learning c++ and i am encountering the problem that if i accidentaly enter a str or char in an int input it starts an infine loop and doesn't allows to enter another set of values please help.
while(true){
int a,b;
cout<<"enter you numbers seperated by space:: ";
cin>>a>>b;
if (isdigit(a) and isdigit(b)){
cout<<"enter a for sum and s for subtraction";
string ans;
cin>>ans;
if (ans=="a"){
cout<<"sum is: "<<a+b<<endl;
}
else if (ans=="s"){
cout<<"difference is: "<<a-b<<endl;
}
else{
cout<<"wrong choice!"<<endl;
}
}
else{
cout<<"wrong input!!";
}
}