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 hadron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!qantel!lll-crg!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: PASSING MULTIDIMENSIONAL ARRAYS Message-ID: <104@hadron.UUCP> Date: Fri, 29-Nov-85 19:15:11 EST Article-I.D.: hadron.104 Posted: Fri Nov 29 19:15:11 1985 Date-Received: Sun, 1-Dec-85 03:32:57 EST References: <138@brl-tgr.ARPA> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 26 Summary: Only with constant dimensions In article <138@brl-tgr.ARPA> jeff@isi-vaxa.arpa (Jeffery A. Cavallaro) 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??? >Calling routine: > struct x a[M][N]; > subrout(M, N, a); >The only way I can see to do it is: > subrout(m, n, a) > struct x *a; >and do the address arithmetic yourself. ... Yes, you could do it the second way; and unfortunately this is the only way to implement a routine that has several different sized matrices being passed to it. However, it seems to me that you are implying a known fixed matrix size in your application. In that case, you can call: struct x a[M][N]; subrout(a) and just declare subrout(arg) struct x arg[M][N]; { ... -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}