How to index a pointer to an array?

Consider an array:

char a[15];

To index a pointer p to this array:

int *p, b[15];

p = b;

By using array index:

p[8] = 145;

By using pointer index:

*(p+8) = 145;

Mostly pointer index is used in programming as it is faster.

Leave a Reply