Pointers and Arrays
mouse at mcgill-vision.UUCP
mouse at mcgill-vision.UUCP
Sat Aug 9 20:13:57 AEST 1986
[ > through >>>> re &array ]
>> If you think about it, a pointer to an int can be used (and is) as a
>> pointer to an array of ints. Unless you apply ++ to it, they are the
>> same thing. (I can already feel the flames approaching).
> I assume Jim really means "unless you apply ++, --, [], *, +, -, +=, or
> -=" (unless I'm overlooking one). That is, unless you use it in
> arithmetic, subscripting, or indirection. Sort of covers what you can
> do with a pointer, doesn't it?
You are overlooking something important. They are the same thing UNTIL
the size of what the pointer points to becomes important. These
situations are:
) ++
) --
) [] with a non-zero subscript
) +
) -
) +=
) -=
As for what they SHOULD be....a pointer to an array should be just
that; indirecting off it should result in an array. There are good
reasons this isn't done; I have yet to hear an implementation suggested
that doesn't have worse flaws than the flaw currently under discussion.
--
der Mouse
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse at uw-beaver.arpa
"Come with me a few minutes, mortal, and we shall talk."
- Thanatos (Piers Anthony's Bearing an Hourglass)
More information about the Comp.lang.c
mailing list