Mail Archives: cygwin/2001/08/26/15:27:33
On Sun, Aug 26, 2001 at 12:04:51PM -0400, Charles Wilson wrote:
>
> Since arrays ARE pointers
They are NOT the same. The only place you can change an array
into a pointer is in a function call, because that is how an
array is passed to a function. You can also do the same
arithmetic with pointers as you can with arrays.
To put it simple, an array allocates storage for data, while the
pointer allocates storage to hold the pointer. You need to make
the pointer point to allocated storage.
There are other differences, like a pointer has a modifiable
lvalue, and an array hasn't.
It also generates different code when you derefence a pointer or
array. With an array, it starts at the addres of the array, and
adds to that, while with a pointer it first has to get the
address it points to, and add to that.
Kurt
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -