[A89] Re: Pointers and Matricies


[A89] Re: Pointers and Matricies

Here's what I would do:

First, define a type for your matrix, for example:

typedef char my_type[rows][cols];

Yeah, I know.  C syntax sucks.
Then define a matrix of that type and initialize it, like:

my_type matrix1 = {...};

Then define a variable holding a pointer to that matrix, like:

my_type *pmatrix = &matrix1;

Then you can access the elements of the matrix that pmatrix points to by
doing the following:

my_value = (*pmatrix)[my_row][my_col];
(*pmatrix)[my_row][my_col] = my_new_value;

Something like that; whatever you want.

If this doesn't work, it's probably my fault, so don't hesitate...