Why is this code snippet infinitely looping?
问题 I'm fairly new to programming, and I'm trying to filter inputs from cin (for no particular reason; It is the only input method I know of right now) such that one can only enter 1-10 and get the "positive" response. Here is my code: #pragma region Check cin is a valid input (an integer between 1 and 10, not a string or number out of range) int input; bool valid2=false; while (!valid2) { cout << "Enter an integer (1-10): "; cin >> input; if (!cin || input > 10 || input < 1) { cout << "Error: