Date: Tue, 13 Jul 1993 18:59:13 -0600 From: jweiss AT silver DOT sdsmt DOT edu (John M. Weiss) To: djgpp AT sun DOT soe DOT clarkson DOT edu Mat Hostetter wrote: There is no reason to use an array of pointers to the beginning of lines if you use the proper C types. I believe this does what you want: #define NROWS 512 #define NCOLS 512 typedef int row[NCOLS]; ... row *my_matrix = (row *) malloc (sizeof (row) * NROWS); my_matrix[123][456] = 7; ... ------------------------------------------------------------------ This is a good technique to be aware of, but not a general solution to dynamically allocating 2-D arrays. The problem is that you may not know NCOLS at compile time. What happens when the image size is, say, 800x600 instead of 512x512? You have to recompile with a new #define. See ALLOC2D.ZIP for a more general solution. - JW