Mail Archives: djgpp/1998/02/14/06:48:36
My dynamic 2D array recipe:
int (*foo)[ysize] = malloc (xsize*ysize*sizeof(int));
/* Mallocked memory for the array and assigned to foo, which is of type
pointer to array of ysize ints. */
/* Check for NULL */
/* ... */
foo[x][y] = bar;
/* ... */
free(foo);
As for C++, it ought to be possible (at least with gnu) to use
foo = new int[y][x];
/* ... */
delete [] foo;
(is it?)
--
.*. Friendship, companionship, love, and having fun are the reasons for
-() < life. All else; sex, money, fame, etc.; are just to get/express these.
`*' Send any and all mail with attachments to the hotmail address please.
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca pgd73 AT hotmail DOT com
- Raw text -