title: c malloc for two dimensional char array by passing this array to function
body: <p>What is wrong with my <strong>char ** array2;</strong> array?</p>
  
  <p>Code below is working correctly when malloc is in main function. But when malloc is in external function ...this doesn't work.</p>
  
  <pre><code>void function(int *var1 ,int array1[][3], char** array2);
  
  main(){
   int var1 = 0
   int array1[10][3];
   char ** array2;
  
   function(&amp;var1 , array1, array2); //Something wrong in here???
  
   printf("Value of var1: %d\n", var1 );                 /*Display 5 - OK*/
   printf("Value of array1[0][0]: %d\n", array1[0][0] ); /*Display 6 - OK */
   printf("Value of array2[0]: %s\n", array2[0]);        /*Error - Function stops here */
  return;
  }
  
  
  
  void function(int *var1 ,int array1[][3], char** array2)
  {
    int i = 0;
    array2= malloc(10 * sizeof(char *));
    for(i = 0; i&lt;10; i++)
    {
      array2[i] =  malloc(10 * sizeof(char *));
      strcpy(array2[i], "SomeText");
    }
  
    *var1 = 5;
  
    array1[0][0] = 6; 
  
    printf("Value of var1: %d\n", var1 );                 /*Display 5 - OK*/
    printf("Value of array1[0][0]: %d\n", array1[0][0] ); /*Display 6 - OK */
    printf("Value of array2[0]: %s\n", array2[0]);        /*Display "SomeText - OK*/
  
   return;
  
  }
  </code></pre>