J
John Harrison
Vivek said:Hello,
I know this is a pretty old topic, and must have been discussed
time and again. I want to the exact reason why a two d array(ex. int
arr[20][10]) can't be accessed using a two d pointer(int **p). In the
posts which I have gone thru, state that the two d array, arr, is an
array of arrays. So, what arr actually points to is the first element
of the 2 d array, this element being an array of 10 integers.
The thing which is not clear is: Consider int b[10], and int * q.
Here b is an array of 10 integers,and can be accessed using the
pointer q.
Simple
int* p;
int a[10];
Each element of a is an int, p points to an int. SAME.
int** p2;
int a2[10][10];
Each element of a2 is an int[10], p2 points to an int*. DIFFERENT.
That's the reason.
john