title: Eight Queens 2-dimensional array with gotos errror
body: <p>I am working on the Eight Queens problem with 2-dimensional array with gotos and when I try to run the code, it gives me a segmentation error and I can not seem to figure out why.
  The eight queens puzzle is the problem of placing eight chess queens on an 8x8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;   
  
  void print(int b[][8]);
  
  int main()
  {
      int b[8][8]={0},  
        r,
        c=0;
      b[0][0]=1; //putting 1st queen piece on the upper left corner
  
      /*column section*/
      next_col:
      ++c; //advance column position
      if(c==8) //if solutions for columns0-7 are found then print
          goto print;
      r = -1; //if not, start at the top of the column
  
      /*row section*/
      next_row:  
      ++r;
      if(r==8)
          goto backtrack;
  
      for(int i=0; i&lt;c; ++i) 
          if(b[r][i] == 1)
              goto next_row;
  
      for(int i=1; (r-i)&gt;=0 &amp;&amp; (c-i)&gt;=0; ++i)
          if(b[r-i][c-i]==1) //if conflict found in updiagonals
              goto next_row;
  
      for(int i=1; (r+i)&lt;8 &amp;&amp; (c-i)&gt;=0; ++i)
          if(b[r+i][c-i] ==1) //if conflict found in down diagonal try next row
              goto next_row;
          else
              b[r][c]=1; //no conflicts found, so place queen &amp; move to next col
      goto next_col;
  
      /*backtrack section*/
      backtrack:
      --c; //go back one column
      if(c== -1) // if past first column, all solutions found so terminate prog
          return 0;
       r = 0; //start looking from first row
       while(b[r][c]!=1) // while we haven't found the queen
           ++r; //move to next row of current column
       b[r][c]=0; //remove queen piece
       goto next_row;
  
       /*print section*/
       print:
       print(b); // print the board
       goto backtrack;
  }   
  
  void print(int b[][8])
  {
      for(int i=0; i&lt;8; i++)
      {
          for(int j=0; j&lt;8; j++)
              cout &lt;&lt; b[i][j] &lt;&lt; " ";
          cout &lt;&lt; endl;
      }
  }
  </code></pre>