title: C array of struct issues
body: <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  struct individual {
      char name[32];
      int stats[7];
      char role;
  };
  
  void create_array(struct individual **array){
      *array = malloc(sizeof(struct individual)); //allocate initial memory space
  }
  
  void resize_array(struct individual **array, unsigned char num) {
      printf(&quot;%d\n&quot;, *array);
      *array = realloc(*array, num * sizeof(struct individual));
      printf(&quot;%d\n&quot;, *array);
      printf(&quot;resize success\n&quot;);
  }
  
  void problem(struct individual **f_array, unsigned char *f_num) {
    *f_num = 2;
  
    printf(&quot;%d\n&quot;, *f_array);
    resize_array(f_array, *f_num);
    printf(&quot;%d\n&quot;, *f_array);
    strcpy(f_array[*f_num - 1]-&gt;name, &quot;test value&quot;); //CRASH LINE
  }
  
  int main() {
  
    unsigned char f_num = 0;
    struct individual *f_array;
    create_array(&amp;f_array);
  
    problem(&amp;f_array, &amp;f_num);
  
  }
  </code></pre>
  <p>This code crashes on the line marked &quot;CRASH LINE&quot;. While it is not shown here, doing this same code setting (*f_num = 1) does not result in an error. While passing *f_array as itself (with appropriate alterations to the code in problem) does not result in an error, the values given after problem is exited result in nonsense being given, as the pointer reverts to it's pre-resize state. Any help appreciated.</p>