Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!ucsdhub!celit!ps From: ps@fps.com (Patricia Shanahan) Newsgroups: comp.lang.c Subject: Re: Passing 2-D Arrays of unknown size ? Message-ID: <5464@celit.fps.com> Date: 20 Dec 89 22:51:57 GMT References: <3180@uceng.UC.EDU> Sender: daemon@fps.com Reply-To: ps@fps.com (Patricia Shanahan) Organization: FPS Computing Inc., San Diego CA Lines: 28 I have sometimes used a macro to represent an array, especially when mixing Fortran and C. #define Array(i,j) array[(i)*cols+(j)] for(i ...) for(j ...) some_operation(Array(i,j)); With more complicated macros, it is possible to handle non-zero base arrays. #define Array(i,j) array[((i)-istart)*cols+(j)-jstart] And of course column-major rather than row-major: #define Array(i,j) array[((j)-jstart)*rows+(i)-istart] And strides: #define Array(i,j) array[((i)-istart)*cols*istride+((j)-jstart)*jstride] In all cases the reference looks like Array(i,j). -- Patricia Shanahan ps@fps.com uucp : {decvax!ucbvax || ihnp4 || philabs}!ucsd!celerity!ps phone: (619) 271-9940