It means the same as a positive index: a[b] is equivalent to *(a + b),
so a[-1] is equivalent to *(a - 1)
If you have a pointer that points into an array (i.e. not at the first
element), a negative index is perfectly legal
eg.
int a[5] = {1, 2, 3, 4, 5};
int *b = a+3;
则 b[-1] = 3;
b[-2] = 2;
阅读(1130) | 评论(0) | 转发(0) |