title: C - malloc array in function and then access array from outside
body: <p>Here is how I malloc an int var and then access this var outside of the function</p>
  
  <pre><code>int f1(int ** b) {
    *b = malloc(sizeof(int)); 
    **b = 5;
  }
  
  int main() {
    int * a;
    f1(&amp;a);
    printf("%d\n", *a);
    // keep it clean : 
    free(a);
    return 0;
  }
  </code></pre>
  
  <p>Using same logic above, how do I malloc a 1 dim array inside a function and then access it outside of the func?</p>
  
  <p>Please help, I am bit confused with pointers to array.</p>