struct b
{
int x;
};
struct b structB = { 222 };
struct a
{
unsigned int MemStartAddr;
unsigned int MemEndAddr;
int CountNum;
struct b* p1;
};
struct a structA = { 2, 3, 4, &structB };
struct a* p = &structA;
int a0 = *((int*)p);
int a1 = *((int*)p + 1);
int a2 = *((int*)p + 2);
struct b** a3 = (struct b**)((int*)p + 3);
int bx = (*a3)->x;
{
int x;
};
struct b structB = { 222 };
struct a
{
unsigned int MemStartAddr;
unsigned int MemEndAddr;
int CountNum;
struct b* p1;
};
struct a structA = { 2, 3, 4, &structB };
struct a* p = &structA;
int a0 = *((int*)p);
int a1 = *((int*)p + 1);
int a2 = *((int*)p + 2);
struct b** a3 = (struct b**)((int*)p + 3);
int bx = (*a3)->x;
本文探讨了C语言中结构体的内存布局及其访问方式。通过具体的实例代码,展示了不同类型的成员变量如何在内存中排列,并解释了如何通过指针访问这些成员变量。
1342

被折叠的 条评论
为什么被折叠?



