title: Segmentation fault: 11 (Sudoku Board)
body: <p>When I try to display my sudoku board in my program, Terminal says: <code>Segmentation fault: 11</code></p>
  
  <p>Here is a copy of my code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  const int DIMEN = 9;
  
  void generate_valid(int [][DIMEN]);
  // generate a valid sudoku solution in a DIMENxDIMEN board
  
  int main()
  {
      int valid_board[DIMEN][DIMEN];
      // Declare the valid board array
  
      generate_valid(valid_board);
      // Initialize the board -- a valid solution
  
      for (int i = 0; i &lt; DIMEN; i++)
      {
          for (int j = 0; i &lt; DIMEN; j++)
          {
              cout &lt;&lt; valid_board[i][j];
              cout &lt;&lt; " ";
          }
          cout &lt;&lt; endl;
      }
      return 0;
  }
  
  void generate_valid(int valid[][DIMEN])
   {
      // initialize the board array -- legit solution
      for( int i = 0; i &lt; DIMEN; i++ ) {
          for( int j = 0; j &lt; DIMEN; j++) {
              // ROW ZERO: 0,1,2,...,9
              if( i == 0 )
                  valid[i][j] = j % DIMEN + 1;
              // ROWS 1 AND 2: 4,5,6... and 7,8,9...
              else if( i == 1 || i == 2 )
                  valid[i][j] = (j + (i*3)) % (DIMEN) + 1;
              // ROWS 3 AND 6: 2,3,4,... and 3,4,5,...
              else if( i % 3 == 0 ) 
                  valid[i][j] = (j + (i/3) ) % DIMEN + 1;
              // ROWS 4 AND 8: 5,6,7,... and 9,1,2,...
              else if (i % 4 == 0 )
                  valid[i][j] = (j+i) % DIMEN + 1;
              // ROW 5: 8,9,1...
              else if( i == 5 )
                  valid[i][j] = (j+7) % DIMEN + 1;
              // ROW 7: 6,7,8,...
              else if( i == 7 )
                  valid[i][j] = (j+5) % DIMEN + 1;
          }
      }
   }
  </code></pre>
  
  <p>What am I doing wrong? From what I've read on other posts about this error, this has to do with the program using an insanely large amount of memory, but this only uses 81 integers total on the sudoku board. </p>