Cout & lt; <"Please enter the gender:" & lt;
While (true)
{
If (sex==1 | | sex==2)
break;
The else
{
Cout & lt; <"Input error, please enter again:" & lt;
}
}
Me to sex is set as integer, 1 represents the male, 2 on behalf of the female, and then set an input conditions, if the input is not 1 or 2 is prompted for mistakes and asked to input, if the input Numbers such as "3" program the normal run has asked me to enter, but if the input is a character like my direct input into "male" or "female" program would have been stuck in a loop inside, don't let me enter again, this is the reason why
CodePudding user response:
Because the type of input is dead, you must be an integer, the input character is a pile of the code