Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 exptools 1/6/84; site ihnet.UUCP Path: utzoo!watmath!clyde!burl!mgnetp!ihnp4!ihnet!eklhad From: eklhad@ihnet.UUCP (K. A. Dahlke) Newsgroups: net.lang.c Subject: Re: malloc(array[][][]), two methods Message-ID: <158@ihnet.UUCP> Date: Fri, 7-Sep-84 14:41:13 EDT Article-I.D.: ihnet.158 Posted: Fri Sep 7 14:41:13 1984 Date-Received: Wed, 12-Sep-84 03:04:16 EDT Organization: AT&T Bell Labs, Naperville, IL Lines: 38 I once had to malloc() a 3-dimensional table. The code was not proprietary, so here is a fragment. mktbl(){ unsigned short (*freq)[ASIZE][ASIZE]; /* malloc a 3-dimensional table of triple frequencies */ freq = (unsigned short ***) malloc(sizeof(unsigned short)*ASIZE*ASIZE*ASIZE); for(i=0;ifreq[0][0][i]=0; ... ++(foo->freq[c1][c2][c3]); ... } The foo-> stuff is annoying to type, but the structures are simpler to understand, and more portable. -- Karl Dahlke ihnp4!ihnet!eklhad