Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site turtlevax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!turtlevax!ken From: ken@turtlevax.UUCP (Ken Turkowski) Newsgroups: net.lang.c Subject: Re: Passing Multidimensional Arrays Message-ID: <985@turtlevax.UUCP> Date: Sun, 8-Dec-85 22:30:52 EST Article-I.D.: turtleva.985 Posted: Sun Dec 8 22:30:52 1985 Date-Received: Tue, 10-Dec-85 07:08:53 EST References: <138@brl-tgr.ARPA> <365@codas.UUCP> Reply-To: ken@turtlevax.UUCP (Ken Turkowski) Organization: CIMLINC, Inc. @ Menlo Park, CA Lines: 23 In article <365@codas.UUCP> mikel@codas.UUCP (Mikel Manitius) writes: >> I have an application where I want to pass a 2D array to a subroutine. >> The data does not easily avail itself to being converted to a 1D array >> of structures. How can one access the array in the subroutine??? > >How about this: >#define X 100 >#define Y 100 >struct x a[Y][X]; >subrout(i, j, a) >int i; int j; struct x *a[]; >{ > ...a[j][i]... >} >And use i and j as boundary limits. Unfortunately, this simplistic approach doesn't work because the offset of a[3][4] from &a[0][0] is not the same when a is declared as a[5][5] versus a[50][50]. -- Ken Turkowski @ CIMLINC, Menlo Park, CA UUCP: {amd,decwrl,hplabs,seismo,spar}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.DEC.COM