Pointers and Arrays

Tainter tainter at ihlpg.UUCP
Thu Jul 24 08:01:50 AEST 1986


> >   After five years of teaching C, I have to agree with my students that
> > it makes no sense to forbid this construct. To take the address of
> > something use the address operator. I have seen this mistake made by
> > students from major universities, and graduates of courses taught by
> > high priced consultants, so it's not just my students.
> 
> All right, tell me:  What is the type of the address of an array?
> 
> That is, suppose I write:
> 
> 	int a[10];
> 
> What type is &a?  Don't tell me it's "pointer to integer" because
> that is the type of &a[0], and a and a[0] are different things.

The answer is : It doesn't have one.  That isn't valid C.  Compilers will
give you warnings about this and interpret it as &a[0], or will give you
an error message (or are broken!).
--j.a.tainter



More information about the Comp.lang.c mailing list