[EMAIL PROTECTED] wrote:
> 
> In C pointers and indexes are different ways
> >to get at, peek into, observe, manipulate, or eavesdrop on, the
> Nevertheless it would not be a good idea for a C programmer to
> confuse an index with a pointer, nor would it be advisable for
> someone, who wants to provide a conceptual theory of C, to confuse
> pointers with indexes.
> 

It would not be a good idea for a C programmer (or someone who wants
to provide a conceptual theory of C) to remain ignorant of the fact
that -- beneath the surface -- indexes and pointers are merely
different means of dealing with the same underlying concept.

   "Rather more surprising, at least at first sight, is the fact
    that a reference to a[i] can also be written as *(a+i).  In
    evaluating a[i], C converts it to *(a+i) immediately; the two
    forms are completely equivalent.  Applying the operator & to
    both parts of this equivalence, it follows that &a[i] and a+i
    are also identical: a+i is the address of the i-th element
    beyond a.  As the other side of this coin, if pa is a pointer,
    expressions may use it with a subscript: pa[i] is identical to
    *(pa+i).  In short, any array and index expression can be
    written as a pointer and offset, and vice versa, even in the
    same statement."

    _The_C_Programming_Language_, B. Kernighan and D. Ritchie
    page 94

-jn-

Reply via email to