title: Bit field structure arrays in C
body: <p>How can I create a bit-field array with variable size?
  The following code is what I tried, which didn't work.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      int n=4;
      struct bite{
          unsigned a1:2;
          unsigned a2:2;
              :
              :
          unsigned a(n-1):2;
          unsigned a(n):2;
      }bits;
  
      for(i=1;i&lt;=n;i++)
          bits.a[i]=i;
  
      for(i=1;i&lt;=n;i++)
          printf("%d ",bits.a[i]);
  
      return 0;
  }
  </code></pre>