c语言中4l存储空间是多少立方米,C语言中数组在内存中如何存储

我在书中看到这段描述

+---+---+---+---+---+---+

a: | h | e | l | l | o |\0 |

+---+---+---+---+---+---+

我在书中看到这段描述

+---+---+---+---+---+---+

a: | h | e | l | l | o |\0 |

+---+---+---+---+---+---+

+-----+ +---+---+---+---+---+---+

p: | *======> | w | o | r | l | d |\0 |

+-----+ +---+---+---+---+---+---+

It is important to realize that a reference like x [3] generates different code depending on whether x is an

array or a pointer. Given the declarations above, when the compiler sees the expression a[3], it emits

code to start at the location ``a,'' move three past it, and fetch the character there. When it sees the

expression p[3], it emits code to start at the location ``p,'' fetch the pointer value there, add three to the

pointer, and finally fetch the character pointed to. In other words, a[3] is three places past (the start of)

the object named a, while p[3] is three places past the object pointed to by p. In the example above,

both a[3] and p[3] happen to be the character 'l', but the compiler gets there differently.

我的问题是 为什么要在字符数组a开始的地方后移动3个字节 才是字符串的开始?还是我误会了这段话的意思

展开

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值