Original Problem
I have an existing 2D array that is already filled with data for a matrix. I also have a structure that has a pointer looking like this double ** pointer.
That being said. Here's a miniature version of the problem
#include <stdio.h>
int main (){
int stuff [2][2];
stuff[0][0] = 1;
stuff[0][1] = 2;
stuff[1][0] = 3;
stuff[1][1] = 4;
int **pointer;
int i;
int j;
pointer = stuff[0][0]; //Here lies the problem: Its an incompatible pointer type
for (i = 0; i < 2; i++){
for (j = 0; j < 2; j++){
printf("%i\n", (*(*(pointer+i)+j)));
}
}
return 0;
}
So my problem with this is that I don't understand pointers well enough to see what is wrong with this. From what I understand, the pointer is pointing at the first memory address of array, but I get the incompatible pointer type problem, which is confusing me. Can someone explain why this is wrong and how it should be properly coded. Thanks.