C++ pointer and array

98 views Asked by At
int arr[]={1,2,3};
int* A=arr;

I wonder if arr is simply an int pointer that points to the first element of the array or if there's any difference between A and arr. Also I wonder: while &arr is the pointer points to the whole array, what does &A point to? I'll appreciate it if somebody could explain how & works for a pointer.

1

There are 1 answers

0
eerorika On

I wonder if arr is simply an int pointer

It isn't. arr is an array, and not a pointer. A is a pointer.

what does &A point to?

Just like &arr points to arr (which is an array), so does &A point to A (which is a pointer).