>are the two arr and &arr same ? , can they be used interchangeably ?
No, and no. The fact that your compiler warns you about it should be a hint that they're not compatible types.
>if not what is the difference ?
A level of indirection. For the following array:
a is almost always treated as the address of the first element (&a[0]), but &a is treated as the address of the array as a whole. The address may be the same, but the types are different. a is a pointer to int and &a is a pointer to an array of ten int.
To use both, you need two different functions:
Code:
#include <stdio.h>
void display1(int* arr,int len){
int i;
printf("display1: ");
for(i = 0; i < len; ++i)
printf("%d ",arr[i]);
printf("\n");
}
void display2(int (*arr)[3],int len){
int i;
printf("display2: ");
for(i = 0; i < len; ++i)
printf("%d ",(*arr)[i]);
printf("\n");
}
int main(void)
{
int arr[] = {1,2,3};
printf("%d %d\n",arr,&arr);
display2(&arr,3);
display1(arr,3);
return 0;
}