Re: the & pointer operator to yield an address
- From: Alef.Veld@xxxxxxxxx
- Date: 31 Jan 2007 01:55:55 -0800
On Jan 31, 1:25 am, gordonb.hr...@xxxxxxxxxxx (Gordon Burditt) wrote:
I sometimes use or see &ptr when passing it through a function so that
this specific function works with the actual pointer passed. But if we
just allocate memory to this pointer before, and then pass it as
func(ptr) instead of func(&ptr), what's the use of the & operator ?
func(ptr) and func(&ptr) pass *DIFFERENT VALUES* and *DIFFERENT
TYPES* to func(). If ptr has type pointer-to-something, &ptr has
type pointer-to-pointer-to-something.
I know that :-). I just wanted to know what the many uses were, seeing
as
you could alloc before and just pass that address.
Often &ptr is passed to func because func is going to store something
in ptr. func(&ptr) is perfectly legal if ptr is uninitialized.
func(ptr) is not.
What happens exactly though if you would do that. It probably just
copy the
'nothingness'/garbage into the new functions argument pointer, making
it
a copy of a unintialized pointer.
Thanks Joe, that's just what i thought to. It's a design matter. I
will have a
look at your ggets function Chuck, thanks.
Kind regards,
alef
.
- Follow-Ups:
- Re: the & pointer operator to yield an address
- From: Harald van Dijk
- Re: the & pointer operator to yield an address
- References:
- the & pointer operator to yield an address
- From: Alef . Veld
- Re: the & pointer operator to yield an address
- From: Gordon Burditt
- the & pointer operator to yield an address
- Prev by Date: Re: How to reduce Zero Initialised region.
- Next by Date: Re: Newbie Problem
- Previous by thread: Re: the & pointer operator to yield an address
- Next by thread: Re: the & pointer operator to yield an address
- Index(es):
Relevant Pages
|