C++ Pointer to an array

Pointer to an array is basically a pointer that points to the address of the first element of the array.

Explanation:

In the above code, the variable total will provide the base address, which is a constant pointer pointing to the first element of the array that is to total[0]. And hence the total will contain the address of total[0]. Thus, the above program fragment assigns p as the address of the first element of the total.

Example:

Output

In this example, ‘p’ will print all the elements present in an array ‘a’.