title: How to pass by reference a sub-array which is in a dynamically allocated 2D array?
body: <p>I need to pass by reference sub-arrays which are part of a dynamically allocated 2D array. I have tried the following approach, which doesn't seem to work. Any ideas if it is possible?  </p>
  
  <pre><code>void set1(int *a){
      a = malloc(2*sizeof(int));
      a[0] = 5;
      a[1] = 6;
  }
  
  void set2(int *a){
      a = malloc(2*sizeof(int));
      a[0] = 7;
      a[1] = 8;
  }
  
  int main(){
      int **x = malloc(2*sizeof(int*));
  
      set1(x[0]);   
      set2(x[1]);
  
      return 0;
  }
  </code></pre>