Date: Wed, 5 Feb 1997 12:06:12 -0500 (EST) From: Nikita Proskourine To: Christian Bird cc: djgpp AT delorie DOT com Subject: Re: Dynamically allocated arrays In-Reply-To: <32F51954.6B69@byu.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 2 Feb 1997, Christian Bird wrote: > struct cell > { > int left, up, right, down, used; > }; > > cell ** maze; I assume you meant cell ** make_maze; > int i; > > make_maze = (cell **) malloc(max_width*sizeof(cell *)); > for (i = 0; i < max_width; i++) make_maze[i] = (cell *) > malloc(max_height*sizeof(cell)); Why not forget pointers-to-pointers and implement a simpler 1D array with cell * make_maze = (cell *)malloc(max_width*max_height*sizeof(cell)); Then you can just pass make_maze to a function and use it as a 1D or 2D array. Also make sure you free(make_maze) when you don't need it. -- Nikita.