Mail Archives: djgpp/2004/02/04/00:48:49
> Newsgroups: comp.os.msdos.djgpp
> Date: 04 Feb 2004 04:19:15 GMT
>
> I would like to use A[i,j,k] instead of A[i][j][k]
You can't really, not with the effect you want it to make.
> (I haven't yet figured out what exactly goes wrong, just changed all
> ][ to , and it compiles but gives strange results)
In C, "i, j, k" is a valid expression: it means "take the value of i,
discard it, take the value of j, discard it, take the value of k". So
A[i, j, k] is the same as simply A[k], probably not what you want.
> What's the difference between the notations ?
The only correct way to reference a 3-dimensional array in C is
A[i][j][k]. If you _must_ use the [i, j, k] notation, the closest
you can get to it is by defining a macro:
#define MA(i,j,k) A[i][j][k]
(note the use of parentheses instead of square brackets), or a similar
definition of an inline function.
- Raw text -