12.4 POINTERS AND ARRAYS
The pointer finds its power when working with arrays. It can work with arrays in a very friendly manner. Consider the following declarations:
int marks[10];
int *p ;
We have declared an array of 10 elements of type integer and a pointer pointing to type integer. Now we set p to point to first array element by
p = &marks[0];
Now *p means marks[0]. Pointer p contains the address of the first array element. If you say (p+3) it will mean you are referring to address of marks[3]. If you say *(p+3) it will mean marks[3]. Our language gives you a still better method of referencing array elements. It allows you to say p[7]. It means marks[7]. Is it not interesting? Use this facility with caution. p[7] is provided to you as shorthand ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access