I create do-while loop that checking input value (below). Only value let to out this loop is 1 and 2. When I put double value ex. 1.2 or 4.5 it's implicit conversion to integer (1 and 4 value). When I put string value, the loop working infinity and I have to close console and debug from the beginning. How can I write correct loop that protect input value from double and string value?
int triangle;
do{
cout << "Put the number (1 or 2): ";
cin >> triangle;
} while (triangle > 2 || triangle < 1 || !cin);