0
  #include <stdio.h>
    struct {
        short a : 2;
        short b : 15;
        char c;
    }abc;
    int main() {
        printf("%d",sizeof(abc));
        return 0;
    }

The total size of "abc" is 4 bytes but when printed it is 6 bytes ? I still don't understand why the size of abc is 6 bytes, **padding bytes** are inserted between which members of the struct ? How many bytes each CPU cycle reads? Thanks for your respond

  • 2
    Does this answer your question? [Why isn't sizeof for a struct equal to the sum of sizeof of each member?](https://stackoverflow.com/questions/119123/why-isnt-sizeof-for-a-struct-equal-to-the-sum-of-sizeof-of-each-member) – ABabin May 01 '23 at 16:13

0 Answers0