PASSING MULTIDIMENSIONAL ARRAYS
Jeffery A. Cavallaro
jeff at isi-vaxa.arpa
Thu Nov 28 09:30:05 AEST 1985
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???
For example:
Calling routine:
struct x a[M][N];
subrout(M, N, a);
C does not have "adjustable arrays" like FORTRAN. So what is one to do?
The only way I can see to do it is:
subrout(m, n, a)
struct x *a;
and do the address arithmetic yourself. I believe that this is OK, because
the innermost (leftmost) index is guaranteed to increase fastest, and
C compilers are required to be consistent about packing when doing
address arithmetic or aggregate allocation (I think).
Any hints???
Thanx,
Jeff
More information about the Comp.lang.c
mailing list