cin for an int inputing a char causes Loop that is supposed to check input to go wild

后端 未结 3 1551
一向
一向 2020-11-29 10:03

This is a function of my game it will ask for input and cin into \"iAuswahl\"! Then the while loop is checks if it is one of the Values i want 1-9 if not it activates and is

3条回答
  •  鱼传尺愫
    2020-11-29 10:28

    If you are not using your iAuswahl variable to do any sort of math, which you aren't in this function, just make the variable a char variable, there is no reason in making a variable an int if it is not doing anything that would require it to be an int.

提交回复
热议问题