Bug in users command
Larry Jones
scjones at thor.UUCP
Fri Jan 25 07:40:57 AEST 1991
In article <1991Jan24.060113.22461 at tkou02.enet.dec.com>, diamond at jit345.swstokyo.dec.com (Norman Diamond) writes:
> [ Given "char (*a)[N];", are "(char *)a", "&(*a)[0]", and "*a" equivalent? ]
>
> No. The last two yield pointers to the same char object, the first char in *a.
>
> The first one coerces a pointer-to-array to a pointer-to-char value.
> The standard guarantees that you can take a pointer-to-something, cast it to
> a pointer-to-char, cast it back to a pointer-to-something, and the result is
> equivalent to the original pointer. It does not guarantee that the value
> with type pointer-to-char can actually be used for anything.
To rephrase, "Is a pointer to an array, when cast to the array element
type, equivalent to a pointer to the first element of the array?"
I believe that the standard imposes sufficient constraints on the
implementation that the answer to that question must be "yes".
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070
Domain: scjones at thor.UUCP Path: uunet!sdrc!thor!scjones
Nobody knows how to pamper like a Mom. -- Calvin
More information about the Comp.std.c
mailing list