0
How to initialise double pointer to 2d array..
In C
5 Réponses
+ 1
int arr[2][2] = {{1,2},{3,4}};
int (*Ptr)[2] = arr;
printf("%d",(*(Ptr+1))[1]); // Displays 4
+ 1
As addition you would probably need such things for passing an array to a function but in C you have to pass dimensions too because pointers doesn't carry any info about length.
Now if you have a function tacking a rectangular matrix you would pass it as plain array and use X and Y dimensions to get values out of it
0
int arr[2][2] = {1,2,3,4};
int **Ptr = arr ;
this is not working
0
John Wells i am asking about double pointer
0
int arr[2][2] = {1,2,3,4};
int* Ptr[] = {arr[0],arr[1]} ;
main(){printf("%d %d %d",Ptr[0][0],Ptr[0][1],Ptr[1][0]);}
You simply can't the way you did.
A double pointer doesn't exist, you probably meant a pointer to pointer which is a pointer to array of pointers to arrays of Type