title: Passing dynamically allocated 2D char array causes segmentation error?
body: <p>I am having trouble using a function.</p>
  
  <p>I have two functions. </p>
  
  <p>createTwoDArray: prompts user for row and column sizes, creates a new 2D array and returns it while also modifying the row and column variables passed to it. </p>
  
  <p>printTwoDArray: should take in a 2d array and print everything. However, when calling this function, segmentation fault occurs immediately. Not one line of code inside the function is called even.</p>
  
  <p>Thank you :)</p>
  
  <pre><code>int column, row;
  char** createTwoDArray(int&amp; column, int&amp; row) {
     int min, max, i, j;
     cout &lt;&lt; "\nPlease enter row size:";
     cin &gt;&gt; i;
     row = i;
     cout &lt;&lt; "\nPlease enter column size:";
     cin &gt;&gt; j;
     column = j;
     char** dynamicArray2 = new char*[column];
     for(i = 0; i &lt; row; i++) {
       dynamicArray2[i] = new char[column];
       for(j = 0; j &lt; column; j++) {
         dynamicArray2[i][j] = '\0';
      }
     }
     return dynamicArray2;
  }
  void printTwoDArray(char** array, int row, int column) {
  //
  }
  
  //
  char** array2 = new createTwoDArray(column, row)
  printTwoDArray(array2, column, row); //this causes the     segmentation error
  //
  </code></pre>