A question in following codes. The result is :
9232312
2
The type of y
in fun
is 'a pointer to a pointer to int
'.Then *y
must be a pointer to int
. So it should printed an address number(like 9232312 etc.), but why is the result 2?
void fun(int **y){
printf("%d\n", *(y+1));
}
int main(){
int a[2][2] = {1,2,3,4};
printf("%d\n", *(a+1));
fun((int **)a);
return 0;
}
It is not the question of pointer or array that I am confused of. I dont understand why the result is different?why the converting from array to pointer occurs error? Apparently your comments and marking my question duplicate are not helping ..