[A89] Re: Pointers and Matricies


[Prev][Next][Index][Thread]

[A89] Re: Pointers and Matricies




| So if I wanted to access the element at 1,1 in the matrix I would do:
|
| *pmatrix[0][0]=1;

I think you're confusing stuff.  Let me see if I got this right: You have a
matrix like this:

my_type matrix1[rows][cols];

Then you create a pointer to reference exactly ONE SINGLE element of the
matrix, like

my_type *pmatrix = &(matrix1[my_row,my_col]);

And now you're using this pointer and try to index it as well???
This will set the element at (0,0) to 1, once the above initialization has
been done:

*pmatrix = 1;

What you might be trying to do is setting a pointer to point to the whole
matrix.  Is this correct?





References: