In C, when is it preferrable to use one over the other?
It is really a matter of style and of coding conventions, since in C p[i]
is defined to be the same as *(p+i)
where p
is a pointer and i
an integral index. AFAIK you could even write i[p]
but that is ugly.
This is not always true in C++ (which gives you the power of defining operator []
etc...).
I personally dislike hand-coding &p[i]
and prefer p+i
in that case.