title: Statically allocated array of pointers to statically allocated structures
body: <p>In this program, there are 100 different runs. For each run, an array of pointers needs to be created. The amount of pointers in each array is determined by a defined constant called NUM_POINTERS. The weird part about this program is that the array must be statically allocated, as well as the data that the pointers are pointing to.</p>
  <p>This is my code:</p>
  <pre><code>for (int j = 0; j &lt; 100; j++){
      SomeType *arr[NUM_POINTERS];
  
      for (int k = 0; k &lt; NUM_POINTERS; k++){
        SomeType blah;
        blah.data = NULL;
        arr[k] = &amp;blah;
      }
  
  }
  </code></pre>
  <p>Now this code does not work at all. It does not create a new array for every run, and if arr[1] is changed, then every other array element gets changed as well.</p>
  <p>I know that the easy way to fix this would be to use malloc, however that would be considered dynamically allocating, not statically. Is there any way to make it work while still having everything statically allocated?</p>