Address operator

int arr[10];
int *a = arr;
I came across this piece of code and had a doubt that why the ‘&’ operator isn’t used while assigning the address of arr to pointer ‘a’ as we do when we use in case of variables. And when use the ‘&’ operator
int *a = &arr;
then it gives an error:
invalid conversion from int to int *

Hey Amol, this is because when we write int arr[10]; here arr will give you the address to the first element of the array, so you can initialize it as int *a = arr;. But when we deal with integers, for eg. int n = 10; then n will give you the value 10 so when you initialize it to a pointer you give the address of n as int* a = &n; .

Thanks for the explanation, cleared with the concept very well.