C++ weird error with variable not being declared in scope, when it clearly is
I'm currently trying use a very simple check using the variable "breakOK", in order to break out of a for loop. If the condition that the current value in my puzzle matrix is set to 46 is satisfied, a function is called and breakOK is set to 1 so that we can break out of the loop. However I get the following errors where I use breakOK in the if statements of the code below:

sudoku.cc:482:13: error: 'breakOK' was not declared in this scope

sudoku.cc:485:11: error: 'breakOK' was not declared in this scope

This is really weird because I declare Guess in the same manner and I do not get a scope error when using it at a later time in my code! Also, the compiler doesn't complain when I set breakOK equal to 1 in the loop. Any help would be much appreciated, I've been stuck on this for too long!


    int Guess = 0; // will be set to a value if a guess is ok

    int breakOk = 0; // will be set to 1 if breaking out of loops is necessary

    for (int row = 0; row < 9; row++)
    {
      for (int col = 0; col < 9; col++)
      {
        if (puzzle.matrix[row][col].currentValue == 46)
        {
          
          Guess = guessValues(row, col, puzzle, tried, allowed);
          breakOk = 1;

        }
        if (Guess != 0)
        {
          tried[row][col].tries.push_back(Guess);
          //puzzle.decide(row, col, Guess);
          puzzle.matrix[row][col].currentValue = Guess;
        }
        if (breakOK == 1) // line 482
          break;
      }
      if (breakOK == 1) // line 485
        break;
    }
C++ weird error with variable not being declared in scope, when it clearly is
===

I'm currently trying use a very simple check using the variable "breakOK", in order to break out of a for loop. If the condition that the current value in my puzzle matrix is set to 46 is satisfied, a function is called and breakOK is set to 1 so that we can break out of the loop. However I get the following errors where I use breakOK in the if statements of the code below:

sudoku.cc:482:13: error: 'breakOK' was not declared in this scope

sudoku.cc:485:11: error: 'breakOK' was not declared in this scope

This is really weird because I declare Guess in the same manner and I do not get a scope error when using it at a later time in my code! Also, the compiler doesn't complain when I set breakOK equal to 1 in the loop. Any help would be much appreciated, I've been stuck on this for too long!


    int Guess = 0; // will be set to a value if a guess is ok

    int breakOk = 0; // will be set to 1 if breaking out of loops is necessary

    for (int row = 0; row < 9; row++)
    {
      for (int col = 0; col < 9; col++)
      {
        if (puzzle.matrix[row][col].currentValue == 46)
        {
          
          Guess = guessValues(row, col, puzzle, tried, allowed);
          breakOk = 1;

        }
        if (Guess != 0)
        {
          tried[row][col].tries.push_back(Guess);
          //puzzle.decide(row, col, Guess);
          puzzle.matrix[row][col].currentValue = Guess;
        }
        if (breakOK == 1) // line 482
          break;
      }
      if (breakOK == 1) // line 485
        break;
    }