C 中的数组索引实际上只是一个指针偏移量。 x[y]与 完全相同*(x + y)。这允许你做这样的事情:
int a[3] = { 1, 2, 3 };
int *p = a; /* p points to a[0] */
printf("p[1]=%d\n", p[1]); /* prints 2 */
p += 2; /* p points to a[2] */
printf("p[-1]=%d\n", p[-1]); /* prints 2 */
Run Code Online (Sandbox Code Playgroud)
这就是允许负数组索引的原因。