首页 > 代码库 > 结构体与指针

结构体与指针

若我们用[0x9999]来标记内存地址,则 *[0x9999]表示该地址内存中存储的数值

变量
int a;
a *[0x9999] 1
&a [0x9999]

指针
int* a;
a *[0x8888] [0x9999]
*a *(*[0x8888]) *[0x9999] 1
&a [0x8888]

结构体变量
struct mystruct
{
int a; [0x9991]
int b; [0x9992]
int c; [0x9993]
}s;

s *[0x9991] 1
&s [0x9991]
s.a *[0x9991] 1
&s.a [0x9991]

结构体指针变量
struct mystruct
{
int a; [0x9999]
int b; [0x999A]
int c; [0x999B]
};

struct mystruct* s;
s *[0x8888] [0x9999]
*s *(*[0x8888]) *[0x9999] 1
&s [0x8888]

s->a *(*[0x8888]) *[0x9999] 1
&s->a [0x9999]
*s->a none

数组(很奇怪)
int a[];
&a [0x9999]
a [0x9999]
*a *[0x9999] 1

a[0] *[0x9999] 1
&a[0] [0x9999]


结构体数组(很奇怪)
struct mystruct
{
int a; [0x9999]
int b; [0x999A]
int c; [0x999B]
};

struct mystruct s[];
s[0].a *[0x9999] 1
s[0] *[0x9999] 1
&s[0] [0x9999]

s [0x9999]
*s *[0x9999] 1
&s [0x9999]