线程断点?

时间:2018-02-15 00:26:11

标签: c++ if-statement

此循环应该提示用户输入1到6之间的值,直到它有5个值。它适用于其他所有数字,但是如果我输入2则表示" Thread1:断点1.1"然后不会崩溃但停止接受输入。 我是C ++的新手,所以我可能会遗漏一些明显的语法方法。

 int userInput = 0;
 int numUserIns = 0;
 int diceRoll1, diceRoll3, diceRoll2, diceRoll4, diceRoll5, diceRoll6;

 int numOnes = 0;
 int numTwos = 0;
 int numThrees = 0;
 int numFours = 0;
 int numFives = 0;
 int numSix = 0;

while (numUserIns <= 5){
    cout << "Enter a number from 1 to 6\n";
    cin >> userInput;
    if (userInput == 1){
        diceRoll1 = userInput;
        numUserIns++;
        numOnes++;
    } else if (userInput == 2){ //not accepting two as input
        diceRoll2 = userInput;  //This line causes error: Thread 1: breakpoint 1.1
        numUserIns++;
        numTwos++;
    } else if (userInput == 3){
        diceRoll3 = userInput;
        numUserIns++;
        numThrees++;
    } else if (userInput == 4){
        diceRoll4 = userInput;
        numUserIns++;
        numFours++;
    } else if (userInput == 5){
        diceRoll5 = userInput;
        numUserIns++;
        numFives++;
    } else if (userInput == 6){
        diceRoll6 = userInput;
        numUserIns++;
        numSix++;
    } else if (userInput < 1 || userInput > 6){
        cout << "invalid input";
        break;
    }
}

1 个答案:

答案 0 :(得分:3)

您似乎在代码中触发了breakpoint。这意味着您的IDE正在停止执行代码,因此您可以在代码中的该步骤查看变量的状态等。大多数IDE左侧都有一个点或箭头,您可以单击它来打开和关闭断点。否则,请查看如何关闭正在使用的IDE的断点。

相关问题