pointers to arrays

Chris Torek chris at mimsy.UUCP
Mon Feb 20 08:48:31 AEST 1989


In article <227300001 at uxa.cso.uiuc.edu> fso10235 at uxa.cso.uiuc.edu writes:
>In your example, you state that E is an "array" and
>then go on to talk about &E.
>
>E is actually an address itself....  This is in K&R, I believe.

No: look again.  If E is declared as an array, then E is actually an
array.  It is true that it is *converted* to a pointer to the first
element of that array *in rvalue contexts*.  The targets of `sizeof'
and `&' are not in rvalue contexts.  The full list of special contexts,
if I remembered them all, is

	sizeof
	unary-&
	lhs of = += -= *= /= %= <<= >>= &= |= ^=
	operand of ++ --
	lhs of `.' (structure selector---actually a special case of `&')

Of these, only `sizeof' does not give lvalue context (sizeof accepts
either lvalues or rvalues, or, with parentheses, types).  Not
surprisingly, sizeof is also the only place in this list that accepts
an array designator.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list