title: Allocating struct with variable length array member
body: <p>I know I can do <code>new char[n]</code> to create an array of <code>n</code> chars. This works even when <code>n</code> is not a compile time constant.</p>
  
  <p>But lets say I wanted a size variable followed by n chars:</p>
  
  <p>My first attempt at this is the following:</p>
  
  <pre><code>struct Test
  {
    std::size_t size;
    char a[];
  };
  </code></pre>
  
  <p>However it seems <code>new Test[n]</code> doesn't do what I expect, and instead allocates <code>n</code> <code>size</code>s.</p>
  
  <p>I've also found that <code>sizeof(std::string)</code> is 4 at ideone, so it seems it can allocate both the size and the char array in one block.</p>
  
  <p>Is there a way I can achieve what I described (presumably what <code>std::string</code> already does)? </p>