CompuServe Messages

#Array vs Structure

    28-Apr-93 08:33:21
Fm: Syndesis 76004,1763
To: Jim Menix 70004,1732
The answer is: it depends. 🙂 If you're storing a number of different items at each cell location, then you might want a matrix of structures. Or, you could have several matrices configured in the same dimensions, each holding one type of item. You also need to consider whether your matrix is fixed or variable in dimensions. If you're worried about speed then other questions come into play, such as the ways you most often access the matrix. There are different optimizations depending on whether you access the matrix randomly, sequentially, by row or by column. If you're new to all this, I'd stick with coding a fixed-dimension doubly-dimensioned array of structures: typedef struct { int color; int contents; int who; } cell; cell Map[64][64];