Address of array

Joseph S. D. Yao jsdy at hadron.UUCP
Thu Mar 27 16:02:19 AEST 1986


In article <2377 at utcsri.UUCP> greg at utcsri.UUCP (Gregory Smith) writes:

a very clear exposition of where I went wrong when I said:

>>               There is no such thing as a pointer to the whole
>>array:  that is a Pasqualische or Fortranian notion.  Pointers, in
>>C, only point to atomic or aggregate (structure/union) objects.

up to the point where he slips off the track:

>                                                       Anyway, array names
>are not always constants; any array which is local to a function has an address
>which is relative to the frame pointer. Also, in
>	struct foo{ int foodle; char foo_line[80]; } *foo_ptr;
>the ARRAY foo_ptr->foo_line doesn't have a constant address, does it?

Well ... this is true, but only the sense that  a n y  address is
relative to the address space in which it lives.  Something is not
a constant if it can be changed, right?  But you cannot say:
	foo_ptr->foo_line++
or
{
	int x[XSIZ];

	x++;
}

Despite the fact that I stupidly said there ain't no array pointers
(and I should know better, I've found where I'd written otherwise!),
I still insist that, the way C treats them right now, the model for
arrays is a pointer constant.  In stack and struct, this translates
to a pointer constant  o f f s e t .
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.lang.c mailing list