title: How can I pass Pointer Matrix to Function in C?
body: <p>I tried what is described in these links:</p>
  
  <p><a href="https://stackoverflow.com/questions/7991194/how-can-i-pass-character-pointer-reference-to-function-and-get-affected-value-ba">How can I pass character pointer reference to function and get affected value back?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38422813/passing-pointers-matrix-to-a-function-in-c">Passing pointers (matrix) to a function in c</a></p>
  
  <p><a href="https://stackoverflow.com/questions/6567742/passing-an-array-as-an-argument-to-a-function-in-c">Passing an array as an argument to a function in C</a></p>
  
  <p>but I can't. Dimension of my array is 3 and I initialized it like this:</p>
  
  <p>char* trips[N][2] = {{"ANKARA", "10:00"}, {"BURSA", "11:00"}, {"IZMIR", "12:00"}, {"ISTANBUL", "13:00"}, {"ANTALYA", "14:00"}}
  so how can I pass this matrix into function?</p>
  
  <p>My code is here and it doesn't sort or effect my array.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define N 10
  
  typedef enum {
    SortByCity,
    SortByHour
   }SortType;
  
  void merge(char**, int, int, int, SortType);
  void mergeSort(char**, int, int, SortType);
  void mergeSortByHour(char**, int, int, SortType);
  
  int main(int argc, char *argv[]) {
   
   int i;
   
   char* trips[N][2] = {{"ANKARA", "10:00"}, {"BURSA", "11:00"}, {"IZMIR", "12:00"}, {"ISTANBUL", "13:00"}, {"ANTALYA", "14:00"}, {"ANKARA", "11:00"}, {"ISTANBUL", "13:00"}, {"ANKARA", "11:30"}, {"BURSA", "21:00"} , {"BURSA", "13:00"}};
   mergeSort(**trips, 0, N-1, SortByCity);
   
   for(i = 0; i &lt; N; i++){
    printf("%-10s %s\n", trips[i][0],  trips[i][1]);
   }
   return 0;
  }
  
  
  void merge(char** T, int L, int M, int H, SortType S){
   
   int i, j, k;
      int N1 = M - L + 1;
      int N2 = H - M;
      
      char* LA[N1][2], RA[N2][2];
      
      for (i = 0; i &lt; N1; i++){
       LA[i][S] = T[L+i][S];
       LA[i][1-S] = T[L+i][1-S];
   }
      for (j = 0; j &lt; N2; j++){
       RA[j][S] = T[L+j][S];
       RA[j][1-S] = T[L+j][1-S];
   }
          
          
      i = 0;
      j = 0;
      k = L;
          
      while (i &lt; N1 &amp;&amp; j &lt; N2)
      {
          if (strcmp(LA[i][S], RA[j][S]))
          {
              T[k][S] = RA[j][S];
              T[k][1-S] = RA[j][1-S];
              j++;
          }
          else
          {
              T[k][S] = LA[i][S];
              T[k][1-S] = LA[i][1-S];
              i++;
          }
          k++;
      }
  }
  
  void mergeSort(char** T, int L, int H, SortType S){
   
   if(L &lt; H)
    return;
    
   int M = (L + H) / 2;
   mergeSort(T, L, M, S);
   mergeSort(T, M+1, H, S);
   merge(T, L, M, H, S);
    
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please dont mark my question as duplicate because I dont understand the solutions explained in the site and can't solve my problem.</p>