suppose i have something like this :
#include<stdio.h>
int main()
{
int arr[2][2][2]={1,2,3,4,5,6,7,8};
printf("%d\n",sizeof(int));
printf("%d\n",&arr[0][1]);
printf("%d\n",&arr[0][1]+1);
printf("%d\n",arr[0][1]);
printf("%d\n",arr[0][1]+1);
printf("%d\n",arr[0]);
printf("%d\n",arr[0]+1);
printf("%d\n",&arr[0]);
printf("%d\n",&arr[0]+1);
printf("%d\n",&arr);
printf("%d\n",&arr+1);
printf("%d\n",arr);
printf("%d\n",arr+1);
return 0;
}
Now when we execute it , the results of printf("%d\n",arr)
,printf("%d",arr+1)
and printf("%d\n",&arr[0])
, printf("%d\n",&arr[0]+1)
are same.
Can someone please explain in a simple layman language what exactly is the difference when using & operator and when not using it. I mean we could only use one way , what is the need for another ??
What's the difference between array and &array?
considering this link,it has been said :
"The type of &array is int ()[16] (a pointer to an array of 16 integers). The type of array, when left to decay, is int (a pointer to an integer)."
how do you exactly determine types of &array and array,and also what is the meaning of "when left to decay" ??