In C language, arrays and pointers
are so closely related that they cannot be studied in isolation. They
are often used interchangeably. The following relationships exist
between arrays and pointers:
- The name of an array refers to the address of the first element of the array, i.e. an expression of array type decomposes to pointer type. Program 12 illustrates this fact.
Program 12. A program to depict the relationship between arrays and pointers
The name of an array refers to the address of the first element of the array but there are two exceptions to this rule:
- In C language, any operation that involves array subscripting is done by using pointers. The expression of form E1[E2] is automatically converted into an equivalent expression of form *(E1+E2). Program 14 illustrates this fact.
Program 14. A program to depict the relationship between arrays and pointers