From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) Newsgroups: comp.os.msdos.djgpp Subject: Re: Dynamically declaring 2-d arrays Date: 14 Feb 1998 11:20:24 GMT Organization: The National Capital FreeNet Message-ID: <6c3ulo$jq@freenet-news.carleton.ca> References: <34DF9744 DOT C7CFDBFE AT ea DOT oac DOT uci DOT edu> Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) NNTP-Posting-Host: freenet3.carleton.ca Lines: 28 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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