Archived

This topic is now archived and is closed to further replies.

shakazed

Why **?

Recommended Posts

quote:
Original post by Typhoon
A pointer to a pointer is used to change values of what a pointer is pointing to, I think.

o_O

No, it''s not. Maybe you''re thinking of the dereferencing operator?

Share this post


Link to post
Share on other sites
quote:
Original post by twix
quote:
Original post by Typhoon
A pointer to a pointer is used to change values of what a pointer is pointing to, I think.

o_O

No, it''s not. Maybe you''re thinking of the dereferencing operator?




Something like this

type **ptr;

a pointer to a pointer.

*ptr will change I thing what a pointer points to and **ptr will change the thing a pointer points is what I meant.

Share this post


Link to post
Share on other sites
a pointer to pointer is just a pointer variable that holds the address of another pointer variable i think..

so if i declare

int **A;
int *B;
int C;

C = 10;

B = &C;

/* *B would equal 10 */

A = &B;

/* pointer to pointer A now holds the address where pointer variable B is located */

A would retrieve the address of B
*A would retrieve the value of B which is the address of C
**A would retrieve the value of C which is 10

Am i Right? I dunno. Plz correct me.

Share this post


Link to post
Share on other sites
Correct DangerDuo. A pointer to a pointer is just that. Its a way to change the address to which the associated pointer is pointing. Typically you see this in things like functions that must change the pointer. They will have a **ptr arguement and would be called like so: func(&ptr); I''ve also heard them called double-pointers as well, saying ''pointer to a pointer'' is kind of a pain, though ''double-pointers'' could be seen as a bit ambiguous.

Ravyne, NYN Interactive Entertainment
[My Site][My School][My Group]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
To further clarify

int main(int argc, char* argv[]) {...}

is equivalent to

int main(int argc, char** argv) {...}

i personally prefer the latter in my programs, ostensibly because it''s easier to type. but really, it''s only a difference of one character. maybe i''m just crazy.

Share this post


Link to post
Share on other sites