Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct __attribute__((packed))
- {
- int elem1;
- long long elem2;
- long elem3;
- } teststruct1;
- typedef struct __attribute__((packed))
- {
- char elem1;
- teststruct1 thestruct;
- char elem3;
- } teststruct2;
- int main()
- {
- teststruct2 temp =
- {
- .elem1 = 'a',
- .thestruct =
- {
- 1,3,5
- },
- .elem3 = 'b'
- };
- //for confirmation
- printf("actual size of testruct1: %d\n", sizeof(teststruct1));
- printf("calculated size of testruct: %d\n", &temp.elem3 - (&temp.elem1 + 1));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement