title: Initializing dynamic array of unions in C
body: <p>I've tried to make an array of union and my code looks like that:</p>
  
  <pre><code>printf("Size of array:");
  scanf_s(" %d", &amp;n);
  
  f* arr = malloc(n * sizeof(float)); 
  </code></pre>
  
  <p>I have my union declared like that:</p>
  
  <pre><code>        union element
      {
          int digit;
          char letter;
          float number;
      } f;
  </code></pre>
  
  <p>And I don't really know how to declare array of unions in C. 
  I tried something like this:</p>
  
  <pre><code>f* arr = malloc(n * sizeof(float)); 
  </code></pre>
  
  <p>and like this:</p>
  
  <pre><code>float* arr = malloc(n * sizeof(float)); 
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>element* arr = malloc(n * sizeof(f)); 
  </code></pre>
  
  <p>Any of them works! </p>
  
  <p>Anyone knows how to do it?</p>