title: Array with uninitialized size inside struct
body: <p>In the program</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  struct t {
          char a[5];
          char b[];
          } temp;
  
  int main(){
          temp.b[0] = 'c';
          temp.b[1] =  'b';
          temp.b[2] = '\0';
          printf("Size of struct = %lu\n", sizeof(temp));
          printf("String is %s\n", temp.b);
  
          printf("Address of temp = %p\n", &amp;temp);
          printf("Address of array a = %p\n", &amp;(temp.a));
          printf("Address of b = %p\n", &amp;(temp.b));
  }
  </code></pre>
  
  <p>with output</p>
  
  <pre><code>Size of struct = 5
  String is cb
  Address of temp = 0x601035
  Address of array a = 0x601035
  Address of b = 0x60103a
  </code></pre>
  
  <p>In this program, how exactly is array b being allocated? How long is it? Is this some undefined behavior, which is only succeeding in the dummy program as I am not doing anything else. Running into gdb, I can access some memory locations initialized as zero, which makes me suspect that it is allocating some memory.</p>
  
  <p>I do have an api that requires me to format one element of struct as int a[][SIZE], and I am confused about that. </p>
  
  <p>Also, why is sizeof not taking into account at least something from array b. I am not sure if it is taking it as an array or pointer.</p>