[A89] Re: Pointers and Matricies
[Prev][Next][Index][Thread]
[A89] Re: Pointers and Matricies
You can not do
char matrix[5][5]=...
char **pmatrix=&matrix;
because the pointer pmatrix does not know anything about the width
of the matrix (it doesn't need to know anything about the height,
but the width is vital; try to uncover why).
Why don't try
char matrix[5][5]=...
char (*pmatrix)[5]=&matrix;
Then you can do
pmatrix[2][3]=whatever_you_want;
In this case, pmatrix is "a pointer to the array of 5 elements".
This is not the same as
char *pmatrix[5]=&matrix;
which is illegal; this makes pmatrix "an array of pointer".
I recommend to you reading about dynamic matrix in the FAQ, and
reading about the asterisk punctuator in TIGCC doc.
Zeljko