I have the following code in C where G
is a global variable:
long *G;
int function(long matrix[35][10]){
G=&matrix[0][0];
}
Once I store the address of matrix[0][0]
in G
, I can access all the elements of matrix
like so:
G[0]=...
G[1]=...
.
.
.
G[349]=...
I want to be able to access all of these elements similar to how I can with matrix
, by using the two square brackets from inside of another function. How would I be able to do that? That is, how can I tell the compiler that the offset for the second dimension in this 2 dimensional array is 10?
I did look at this answer: Create a pointer to two-dimensional array , but I'm not sure if the user asked the exact same thing. Please correct me if I'm wrong