码迷,mamicode.com
首页 > 其他好文 > 详细

结构体与指针

时间:2014-08-12 16:39:44      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:amp   on   sp   存储   指针   内存   数组   结构   

若我们用[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]

 

结构体与指针,布布扣,bubuko.com

结构体与指针

标签:amp   on   sp   存储   指针   内存   数组   结构   

原文地址:http://www.cnblogs.com/cation/p/3907258.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!