各位牛人:小弟请教个结构体的问题,有点意思的
定义两个结构体如下:
typedef struct
{
short b1;
int a1;
}ST1;
typedef struct
{
short b2;
int a2;
ST1 P1;
ST1 P2;
}ST2;
。。。。
unsigned int offset;
offset = (unsigned int) &( ( (ST2*)0)->P1 );//offset = 8
offset = (unsigned int) &( ( (ST2*)1)->P1 ) ;////offset = 9
...
为什么会出现这种情况呢?小弟不百思不得其解!!
((ST2*)0)这样写法的内存又是如何处理的呢??
请教了!!!!
typedef struct
{
short b1;
int a1;
}ST1;
typedef struct
{
short b2;
int a2;
ST1 P1;
ST1 P2;
}ST2;
。。。。
unsigned int offset;
offset = (unsigned int) &( ( (ST2*)0)->P1 );//offset = 8
offset = (unsigned int) &( ( (ST2*)1)->P1 ) ;////offset = 9
...
为什么会出现这种情况呢?小弟不百思不得其解!!
((ST2*)0)这样写法的内存又是如何处理的呢??
请教了!!!!
...全文


