Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!jarthur!dfoster From: dfoster@jarthur.Claremont.EDU (Derek R. Foster) Newsgroups: comp.lang.c Subject: (Peter Lim take note!) Declaring very large global array Message-ID: <6242@jarthur.Claremont.EDU> Date: 14 Apr 90 21:51:17 GMT References: <18817@oregon.uoregon.edu> <15080006@hpfinote.HP.COM> Organization: Harvey Mudd College, Claremont, CA 91711 Lines: 46 On declaring arrays like data[MAX_CHANNELS][MAX_SAMPLES] with MAX_CHANNELS = 6, MAX_SAMPLES = 3000 (Which runs up against the old >64K array problem) People, PLEASE! Realize there's a better way to do this! You don't need to fill your programs with *(pointer+j)[i] 's! You can just use pointer[i][j] 's! Watch... In article <15080006@hpfinote.HP.COM> pnl@hpfinote.HP.COM (Peter Lim) writes: >You need to play with pointers. In your case, why don't just declare >an array of 6 pointers, each is then used to index 3000 samples. Like: > >float (*dptr)[MAX_CHANNELS]; > >for (i=0; i < MAX_CHANNELS; i++) > (*dptr)[i] = (float *) malloc ((unsigned) (MAX_SAMPLES * sizeof (float))); > >then proceed to use > (*(dptr+j))[i] ..... in place of data[i][j]. There is a MUCH nicer way. Just do this: float * data[MAX_CHANNELS]; for (i=0; iRegards, ## Life is fast enough as it is ........ >Peter Lim. ## .... DON'T PUSH IT !! >>>-------, > ########################################### : >E-mail: plim@hpsgwg.HP.COM Snail-mail: Hewlett Packard Singapore, : >Tel: (065)-279-2289 (ICDS, ICS) | >Telnet: 520-2289 1150 Depot Road, __\@/__ > ... also at: pnl@hpfipnl.HP.COM Singapore 0410. SPLAT ! Derek Riippa Foster