结构体内存对齐——2
发布日期:2021-05-14 09:05:24 浏览次数:11 分类:精选文章

本文共 1207 字,大约阅读时间需要 4 分钟。

���������������������������

���������������������������������������������������������������������������������������������������������������GIF������������������������������������������

#pragma pack(1)  struct gif_hdr  {      char signature[3];      char version[3];      int width;      char height;      char colormap;      char bgcolor;      char ratio;  } __attribute__((aligned(4)));  // ���������������������  struct gif_hdr v1 = {1,2,3,4,5,6,7,8,9,10,11};  struct gif_hdr *dsptr;  // ���������������������  dsptr = (struct gif_hdr *)malloc(sizeof(struct gif_hdr));  // ���������������������������������  printf("������������������%p\n", dsptr);  printf("������������������%d\n", sizeof(struct gif_hdr));  // ���������������������������  printf("������������������Offset\n");  printf("signature[0]���%p\n", dsptr->signature[0]);  printf("version[0]���%p\n", dsptr->version[0]);  printf("width���%p Offset\n", (char *)dsptr->width, dsptr->signature[0]);

���������������

������������������006E1898

������������������16
signature[0]���006E1898 Offset
version[0]���006E189B Offset
width���006E18A0 Offset
height���006E18A4 Offset
colormap���006E18A5 Offset
bgcolor���006E18A6 Offset
ratio���006E18A7 Offset

上一篇:链表——新建链表
下一篇:结构体内存对齐_1

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年04月21日 18时02分38秒