From: "DeHackEd" References: <34ae5551 DOT 4918923 AT 195 DOT 10 DOT 154 DOT 8> Subject: Re: New and multidimensional array Date: Mon, 5 Jan 1998 17:07:14 -0500 Lines: 37 Message-ID: <#ChxQYiG9GA.225@upnetnews03> Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I don't know about the easiest, but this worked for me and if DJGPP doesn't give an error, it works. void **make_2d_array(size_t element_size, size_t left, size_t right) { // array[left][right] for clarity void **ret; int i; // how do you 'new' a number like malloc()? ret = malloc(4 * left); // array of far pointers if (!ret) return NULL; for (i = 0; i < right; i++) ret[i] = malloc(element_size * right); for (i = 0; i < right; i++) if (!ret[i]) return NULL; return ret; } This worked for me, though it seems to be a large waste. -- "DeHackEd" Remove "nospam." from my email address to reply. It's too late to run when you hear the boom. Aleksi Kallio wrote in message <34ae5551 DOT 4918923 AT 195 DOT 10 DOT 154 DOT 8>... >What's the easiest way to reserve memory for multidimensional array >with "new"? > > |Mikko Aleksi Kallio | > |akallio AT finlink DOT net | > |www.finlink.net/~akallio/ |