Newsgroups: comp.lang.c
Path: utzoo!censor!geac!maccs!rory
From: rory@maccs.dcss.mcmaster.ca (Rory Jacobs)
Subject: Re: sizeof and multi-dimensional arrays
Message-ID: <27864969.22400@maccs.dcss.mcmaster.ca>
Organization: McMaster University, Hamilton, Ontario, Canada
References: <1991Jan5.050613.22303@Neon.Stanford.EDU> <fred.663069060@prisma> <4596@sactoh0.SAC.CA.US>
Date: Sat, 5 Jan 91 21:47:21 GMT

In article <4596@sactoh0.SAC.CA.US> jak@sactoh0.SAC.CA.US (Jay A. Konigsberg) writes:

>sizeof(*x)   DOES NOT make sense. The size of a pointer on this machine
>	     is 4 bytes. (Note: adding "char *y; sizeof(y) does return 4).
>

But it does make sense.

In a sense the array name is a pointer to the array.  To access
the i-th element in an array you could write
   foo[i]

or

   *(foo + i)

Both statements return the i-th element.  

Now back to the orignal problem, since the above is true (convient
as pointer arithmatic is faster than array indexing) *x is equivalent
to *(x+0) which is x[0], and thus they have the same size.

Hope this helps,
   Rory

Rory Jacobs                                   Who me?!?
rory@maccs.dcss.mcmaster.ca                   Let's go Flyers!
...!uunet!uati!utgpu!maccs!rory               I thought it was easy...
Department of Computer Science and Systems    Boring (yawn)!
McMaster University, Hamilton, Ont            Let's have some fun.

