[comp.lang.c] meaning of "string constants" in C

throopw@xyzzy.UUCP (Wayne A. Throop) (08/29/87)

> jay@splut.UUCP (Jay Maynard)
> In article <8088@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes:
>> Eventually it seems to dawn upon these programmers that
>> 	"LDA"
>> generates an anonymous character array holding the letters L, D,
>> A, and NUL (\0) and evaluates to the address of this array.

Oooooh!  I didn't catch *THIS* the first time around.  A small slip on
(apparently) Chris's part, but an important distinction all the same.
It does not, I repeat *NOT* evaluate to the address of the array.  It
evaluates to the address of the first element in the array, namely the
'L' in "LDA".

Naturally, this distinction has important consequences when this array
is used in subscripting or in pointer arithmetic.  I hope everybody sees
how "the address of the array" and "the address of the first element of
the array" differ in these important ways.

--
It is easy to find fault, if one has that disposition.  There was once a
man who, not being able to find any other fault with his coal,
complained that there were too many prehistoric toads in it.
                                --- Pudd'nhead Wilson's Calendar (Mark Twain)
-- 
Wayne Throop      <the-known-world>!mcnc!rti!xyzzy!throopw

chris@mimsy.UUCP (08/30/87)

In article <231@xyzzy.UUCP> throopw@xyzzy.UUCP (Wayne A. Throop) writes:
>["string"] does not, I repeat *NOT* evaluate to the address of the
>array.  It evaluates to the address of the first element in the array,
>namely the 'L' in "LDA".

Oops!  I abase myself, etc., &c.  The type of "foo" is indeed
pointer to char, not pointer to array 4 of char.

(Sorry about that.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	seismo!mimsy!chris