//User input
cout << "Please enter the property value: ";
while (true)
{
cin >> property_value;
if (cin.fail())
{
cout << "Please enter the valid data." << endl;
cout << "Please enter the property value again:" << endl;
}
else
{
break;
}
}
I want to ask the user to reinput again when the user input the invalid data, e.g. some letters. However when I try to run it, it keeps showing "Please enter the valid data." and "Please enter the property value again:", it enters an infinite loop. I already check some post also about this problem, but my code is similar to them. Please help. P.S. sorry for my bad english.