void fun(int* array){}
int main(){
int array[]={1,2,3};
fun(&array);----->(1)//error in this line
return 0;
}
error: cannot convert â
They don't work because they imply different element sizes. Indexing an int*
increases it's address by sizeof(int)
, as it indexes into an array of int
. Indexing an int(*)[3]
increases it's address by sizeof(int) * 3
, as it indexes into an array of arrays of 3 ints. Thus, even though the starting address is the same, they are very different types and imply very different pointer arithmetic. The compiler is quite correct to tell you that they are not compatible.