Passing Multi-dimensional arrays to a function
Karl Heuer
karl at haddock.ima.isc.com
Thu Jul 19 05:38:56 AEST 1990
In article <9905 at crdgw1.crd.ge.com> volpe at underdog.crd.ge.com (Christopher R Volpe) writes:
>In article <1990Jul17.224910.20086 at DRD.Com>, tdh at DRD.Com (Tom Haynes) writes:
>> char buf[SCREEN][COLS][MAX_SCREEN];
>
>Beats me, buf is of type (char ***), and that's what the formal parameter
>wants.
No, it isn't. buf is of type `char[SCREEN][COLS][MAX_SCREEN]', which (being
an array type) will decay into `char (*)[COLS][MAX_SCREEN]', i.e. pointer to
array of array of char. If every object being passed through this parameter
has type `char (*)[COLS][MAX_SCREEN]', then you can declare the parameter to
have that type. Otherwise, your best bet is to allocate `buf' at runtime
using dope vectors, so that it really does have type `char ***'.
Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
More information about the Comp.lang.c
mailing list