Message-ID: <35B0ADBC.389CD3CE@ipass.net> From: Terry MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: big matrix/array References: <35D0C6B0BF1 AT cyberlib DOT itb DOT ac DOT id.> <35AAEC96 DOT 2893C89E AT cartsys DOT com> <35b0151a DOT 9633555 AT news DOT rmi DOT net> <6opo4m$8nv AT news-central DOT tiac DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 41 Date: Sat, 18 Jul 1998 14:20:05 GMT NNTP-Posting-Host: ts8-130-ppp.ipass.net NNTP-Posting-Date: Sat, 18 Jul 1998 10:20:05 EDT Organization: iPass.Net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Martin Ambuhl wrote: > > John Meyer wrote in message <35b0151a DOT 9633555 AT news DOT rmi DOT net>... > |On Mon, 13 Jul 1998 22:28:54 -0700, Nate Eldredge > |wrote: > | > |>int a[3000][3000]; > | > | > |Okay, but how do you make an array dynamic? > =========== > #include > int main(void) > { > int *a; > if (!(a = malloc(9000000))) exit(EXIT_FAILURE); > /* do stuff */ > free(a); > return 0; > } > > Martin Ambuhl (mambuhl AT tiac DOT net) > /* Newsgroup posts also e-mailed */ An alternative would be: #include int main(void) { int **a; int i; a = (int **) malloc(3000*sizeof(int)); for(i=0;i<3000;i++) a[i] = (int *) malloc(3000*sizeof(int); .... /* to free memory */ for(i=0;i<3000;i++) free(a[i]); free(a); }