boot2

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

027-sizeof-types.c (553B)


      1 // tests/cc-parse/27-sizeof-types.c — sizeof over struct, array, ptr,
      2 // char, plus the named integer types (§C.2). Sums to a known total.
      3 struct S { int a; int b; };
      4 int main(void) {
      5     int sum = 0;
      6     sum += sizeof(char);            // 1
      7     sum += sizeof(short);           // 2
      8     sum += sizeof(int);             // 4
      9     sum += sizeof(long);            // 8
     10     sum += sizeof(int *);           // 8
     11     sum += sizeof(int[5]);          // 20
     12     sum += sizeof(struct S);        // 8
     13     return sum;                     // 1+2+4+8+8+20+8 = 51
     14 }