boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

242-init-brace-elision-array-struct.c (400B)


      1 // tests/cc/242-init-brace-elision-array-struct.c — brace elision in
      2 // nested arrays of arrays. C99 §6.7.8 ¶22.
      3 //
      4 // int m[2][2] = {1,2,3,4} should fill m[0][0]=1, m[0][1]=2,
      5 // m[1][0]=3, m[1][1]=4. Sum proves all four cells received the right
      6 // value (1+2+3+4 = 10).
      7 int main(void) {
      8     int m[2][2] = { 1, 2, 3, 4 };
      9     int *p = (int *)m;
     10     return *p + *(p + 1) + *(p + 2) + *(p + 3);
     11 }