title: How to include a dynamic array INSIDE a struct in C?
body: <p>I have looked around but have been unable to find a solution to what must be a well asked question.
  Here is the code I have:</p>
  
  <pre><code> #include &lt;stdlib.h&gt;
  
  struct my_struct {
      int n;
      char s[]
  };
  
  int main()
  {
      struct my_struct ms;
      ms.s = malloc(sizeof(char*)*50);
  }
  </code></pre>
  
  <p>and here is the error gcc gives me:
  error: invalid use of flexible array member</p>
  
  <p>I can get it to compile if i declare the declaration of s inside the struct to be </p>
  
  <pre><code>char* s
  </code></pre>
  
  <p>and this is probably a superior implementation (pointer arithmetic is faster than arrays, yes?)
  but I thought in c a declaration of</p>
  
  <pre><code>char s[]
  </code></pre>
  
  <p>is the same as</p>
  
  <pre><code>char* s
  </code></pre>