I have a quick question about the nature of making a 2D array using pointers, as in
int **v;
I tried making a little piece of code like this:
int **twoDee;
int i, j;
twoDee = (int**)malloc(X*Y*sizeof(int));
twoDee[2][1] = 5;
printf("%d", twoDee[2][1]);
This was just so I could try and access twoDee after initializing it and assigning a variable. However, the program crashes before anything is printed there, so I guess I'm unaware of the proper syntax. Can someone show me what it is?
int **v;
I tried making a little piece of code like this:
int **twoDee;
int i, j;
twoDee = (int**)malloc(X*Y*sizeof(int));
twoDee[2][1] = 5;
printf("%d", twoDee[2][1]);
This was just so I could try and access twoDee after initializing it and assigning a variable. However, the program crashes before anything is printed there, so I guess I'm unaware of the proper syntax. Can someone show me what it is?