Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * # gcc main.c -o main
- * # ./main
- * Size results:
- *
- * struct: 9
- * int #1: 4
- * int #2: 4
- * char #1: 1
- */
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct Test
- {
- int a;
- int b;
- char c;
- } __attribute__((packed)) Test;
- int main(void)
- {
- Test *obj = (Test*)malloc(sizeof(Test));
- printf("Size results:\r\n\r\nstruct: %i\r\nint #1: %i\r\nint #2: %i\r\nchar #1: %i\r\n",
- sizeof(Test), sizeof(obj->a), sizeof(obj->b), sizeof(obj->c));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement