From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Q: Typedef riddle Date: Mon, 18 Nov 1996 18:43:35 -0800 Organization: Three pounds of chaos and a pinch of salt Lines: 32 Message-ID: <32911ED7.49C9@cs.com> References: Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp108.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: bartosz AT hostr DOT bielbit DOT bielsko DOT pl To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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 -----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------