title: Bug in a function in C++
body: <p>I'm currently making a minesweeper game on C++, but there seems to be a bug. There's a function I wrote to return the amount of mines around the spot, just like in a classic game of minesweeper. However, the code fails near the end. I have provided some code to better explain.</p>
  <pre><code>int findBeginnerMines(string actualBoard[BEGINNER_DIMENSION][BEGINNER_DIMENSION], int x, int y)
  {
      int mines = 0;
      
      if (actualBoard[x][y] == MINE)
      {
          mines = -1;
      }
      
      else
      {
          if (actualBoard[x - 1][y - 1] == MINE)
          {
              mines++;
          }
          
          if (actualBoard[x][y - 1] == MINE)
          {
              mines++;
          }
          
          if (actualBoard[x + 1][y - 1] == MINE &amp;&amp; x != BEGINNER_DIMENSION - 1)
          {
              mines++;
          }
          
          if (actualBoard[x - 1][y] == MINE)
          {
              mines++;
          }
          
          if (actualBoard[x + 1][y] == MINE &amp;&amp; x != BEGINNER_DIMENSION - 1)
          {
              mines++;
          }
          
          if (actualBoard[x - 1][y + 1] == MINE &amp;&amp; y != BEGINNER_DIMENSION - 1)
          {
              mines++;
          }
          
          if (actualBoard[x][y + 1] == MINE &amp;&amp; y != BEGINNER_DIMENSION - 1)
          {
              mines++;
          }
          
          if (actualBoard[x + 1][y + 1] == MINE &amp;&amp; x != BEGINNER_DIMENSION - 1 &amp;&amp; y != BEGINNER_DIMENSION - 1)
          {
              mines++;
          }
      }
      return mines;
  }
  </code></pre>
  <p>In this case, BEGINNER_DIMENSION = 8. When x = 7, this function returns an error.</p>