Mail Archives: djgpp/1996/11/19/04:10:42
bartosz AT hostr DOT bielbit DOT bielsko DOT pl wrote:
>
> > void Dump(thing *V)
> > {
> > printf("\n%i %i %i\n",*V[0],*V[1],*V[2]);
>
> ^ ??????
>
> Why are you using * operator. To get value of the 0 element you jaust
> need V[0]. If you use *V[0] you traet V[0] as a pointer.
That's NOT correct. In that code, what is being passed to the function
Dump() isn't the array V, but a pointer to the array V. So, to access
the array itself you need an extra dereference. The problem with
Elliot's code was that it confused the precedence of the dereference
operator vs. the array operator.
Remember that 'thing' is a typedef that itself represents an array of
integers, so passing a reference to a 'thing' requires double
dereference to access the array itself. To see this, take the code and
replace all references to 'thing' with the actual typedef, and you'll
understand.
--
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>+ W++ N++ o+ K? w(---) O-
M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+ tv+() b+++ DI++ D++ G e(*)>++++
h!() !r !y+()
------END GEEK CODE BLOCK------
- Raw text -