I am not able to understand the topic. Please help me to understand how the pointer and array is linked
Array and pointer
array name itself act as the pointer …
for example …
void main()
{
int arr[]={1,2,3,4}; //define a array
//if you take array name only that is ‘arr’ only …then it is act as a pointer which is always points to the first element of array
cout<<&arr<<endl; //it print the address of array first element
cout<<&arr[0]<<endl; //it also print the address of array first element
cout<<*arr<<endl; //it print arr[0] value that is output come is 1 bcoz 'arr' is act as a
//pointer which points to first element to array
cout<<*(arr+1); //it print the second element of array;
}
Hi
The name of array is the address of the first element and from array[0] u access it value