c++ - 线程断点?

标签 c++ if-statement

这个循环应该提示用户输入从 1 到 6 的值,直到它有 5 个值。它适用于所有其他数字,但如果我输入 2,它会显示“线程 1:断点 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;
    }
}

最佳答案

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

关于c++ - 线程断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48798388/

相关文章:

c++ - fstream - 如何 seekg() 以从末尾定位 x

c++ - 将结构的枚举传递给其他函数并分配值

mysql - SQL - 仅 if 语句

android - textView 不显示输出

c++ - 数组中第 k 个最大的元素

c++ - std::merge 和 std::inplace_merge 之间的区别?

c++ - 可以优化 b&&0

java - if(false){some code} 在 java 中是什么意思

c# - 允许用户在 Windows 控制台中键入任意数量的字符串,然后显示有关已键入的字符串中的字母数和行号的信息

bash - Bash 脚本中的字符串比较未按预期工作