Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!think!ima!haddock!karl From: karl@haddock Newsgroups: net.lang.c Subject: Re: Pointers and Arrays Message-ID: <86900010@haddock> Date: Wed, 13-Aug-86 13:03:00 EDT Article-I.D.: haddock.86900010 Posted: Wed Aug 13 13:03:00 1986 Date-Received: Thu, 14-Aug-86 06:15:19 EDT References: <513@hadron.UUCP> Lines: 21 Nf-ID: #R:hadron.UUCP:513:haddock:86900010:000:1082 Nf-From: haddock!karl Aug 13 13:03:00 1986 hadron!jsdy writes: >I have seen several references to the address of an array vs. >the address of the first element of the array. Would someone >care to address what they think this difference is, aside from >data type? On most machines, as you imply, &a and &a[0] do indeed have the same bit-pattern, and will compare equal if you cast them to a common type. If, however, you want to *do* something with the pointer (*, [], +, -, ++, --, etc.) you'd better have the correct type as well as value. In particular, the effect of ++p on an int(*)[] is not the same as on an int*. Btw, someone suggested earlier that ANSI C doesn't interpret &a as pointer to array. I think it does: "The operand of the unary & operator shall be a function locator or an lvalue [other than bit-field or register]. ... The result ... is a pointer to the object [and has type] `pointer to _t_y_p_e'." (3.3.3.2, 01-May-1986 draft.) Arrays are not mentioned as a special case. And yes, arrays *are* (non-modifiable) lvalues in X3J11. Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint