Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC830713); site vu44.UUCP Path: utzoo!linus!philabs!mcvax!vu44!jack From: jack@vu44.UUCP (Jack Jansen) Newsgroups: net.lang.c Subject: Re: Help with malloc(): datum ** and [i][j] Message-ID: <374@vu44.UUCP> Date: Tue, 28-Aug-84 02:35:47 EDT Article-I.D.: vu44.374 Posted: Tue Aug 28 02:35:47 1984 Date-Received: Thu, 30-Aug-84 08:43:57 EDT References: <12365@sri-arpa.UUCP> <461@sjuvax.UUCP> <8131@umcp-cs.UUCP> Organization: VU Informatica, Amsterdam Lines: 17 Chris Torek: > Think of it this way: suppose the array is declared as > > int a[20][50]; > > Suppose we're asked to fetch a[6][4]. .... > > The other way we could do it is multiply the 4 times the 50 and add > 6; that is, start with the second subscript and multiply it by the > second subscript size, then add the first subscript. From here we > do the same thing as before. So add 206 to ``a'' and fetch from there. > If I haven't got them reversed this is ``column major'' order. Sorry Chris, but I think this is wrong. What you should do is multiply the second subscript by the *first* subscript size, and add the first subscript, or, in this example use 4*20+6, or 86. Jack Jansen, {philabs|decvax}!mcvax!vu44!jack