title: Random maze generator in C
body: <p>I don't know how to make sure the random maze can lead from the entry on the right side to the exit on the left side without any wall block the path. This is my code I am doing so far. Can everybody give me a hint or algorithm to achieve the simple maze (entry/exit)? Thank you!
  P/S my problem is the maze generator doesn't ensure the path to the exit...(get stuck)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define SIZE 12
  void mazeGenerator(char [][SIZE]);
  
  int main(void)
  {
      char maze[SIZE][SIZE];
      srand((unsigned int)time(NULL));
      mazeGenerator(maze);
      return 0;
  }
  void mazeGenerator(char a[SIZE][SIZE])
  {
      size_t row,column = 0, r;
  
      // initialize '#' to all positions of left-hand wall
      for ( row = 0; row &lt; SIZE; ++row )
      {
          a[row][column] = '#';
      }
      // initialize '#' to all positions of left-hand wall
      for ( row = 0; row &lt; SIZE; ++row )
      {
          a[row][SIZE - 1] = '#';
      }
  
      // initialize '.' to left-hand wall random positions from 1 -&gt; 10
      row = rand() % 11 + 1;
      a[row][0] = '.';
  
      // initialize '.' to right-hand wall random positions from 1 -&gt; 10
      row = rand() % 11 + 1;
      a[row][SIZE - 1] = '.';
  
      // intialize '#' to all positions of top maze
      for (column = 1; column &lt; SIZE - 1; ++column)
      {
          a[0][column] = '#';
      }
  
      // intialize '#' to all positions of bottom maze
      for (column = 1; column &lt; SIZE - 1; ++column)
      {
          a[SIZE - 1][column] = '#';
      }
  
      // print maze
      puts("");
      puts("** Maze Generator by Huy Le **\n");
      for (row = 0; row &lt; SIZE; ++row)
      {
          for (column = 0; column &lt; SIZE; ++column)
          {
              printf_s("%2c",a[row][column]);
          }
          puts("");
      }
      puts("");
  }
  </code></pre>