title: C. malloc() and free() in function doesn't work
body: <p>Can someone tell me, why I can't allocate memory to the struct array through the <strong>init()</strong> function? When done manually in main, everything is fine. When trying it through <strong>init()</strong> nothing happens (Also no error message). The adress is always 0x0, I guess the null pointer.</p>
  <pre class="lang-c prettyprint-override"><code>#define GAMES 100
  
  typedef struct{
    double *scores;
  }SCORES;
  
  void init(SCORES *arr);
  
  int main(){
    SCORES *numbers = NULL;
    init(numbers);
  
    printf(&quot;Adress is: %p\n&quot;, numbers);      //Still 0x0
    return 0;
  }
  
  
  
  void init(SCORES *arr){
    arr = (SCORES*) malloc(GAMES * sizeof(SCORES));
  }
  </code></pre>
  <p>Trying it with the code below works for malloc. I get an adress but if I use <strong>free()</strong>, memory is still allocated.</p>
  <pre class="lang-c prettyprint-override"><code>
  void init(SCORES **arr){
    *arr = (SCORES*) malloc(GAMES * sizeof(SCORES));
  }
  
  ...
  
  init(&amp;numbers);
  
  ...
  
  free(numbers);
  </code></pre>