By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,052 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,052 IT Pros & Developers. It's quick & easy.

pointer to pointer

P: n/a
hi
could someone tell me a good website that explains pointer to pointers well.
Not just simple stuff like 2d arrays passing , or pointing to another int
variab.le
May 30 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
jagguy wrote:
hi
could someone tell me a good website that explains pointer to pointers well.
Not just simple stuff like 2d arrays passing , or pointing to another int
variab.le


Not sure that there is one - how hard can it be really.
*p returns a reference to whatever p points to. If p points to a pointer,
**p returns a reference to whatever that pointer points to.

There's one for function pointers though, since they have tricky syntax (function-pointer.org ?).

What do you want to do?
Many times pointer wrangling can be replaced by something safer and easier to work with.

Sorry to be of little help

homsan
May 30 '06 #2

P: n/a
jagguy posted:
hi
could someone tell me a good website that explains pointer to pointers
well. Not just simple stuff like 2d arrays passing , or pointing to
another int variable

A pointer variable stores a memory address. Plain and simple.

If it's a pointer variable of any kind, it stores a memory address.

The following variable stores an integer:

int k;
The following variable stores a memory address:

int *p;
It doesn't just store ANY memory address though, it's supposed to store
the memory address of an "int".

How do we store the memory address of an "int*". Simple, with a pointer
to an "int*":
int **pp;
Here's a sample:

int main()
{
int k = 5;

int *p = &k;

int **pp = &p;

int ***ppp = &pp;

int ****pppp = &ppp;

int *****ppppp = &pppp;
*****ppppp = 7;

}
-Tomás
May 30 '06 #3

P: n/a
Here is slightly complicated example using **pointers:

class Boo
{
int num;
Boo* next;
} ;

void main()
{
Boo emp1, emp2, *pointer0, **pointer1;

pointer0 =&emp1; //point pointer0 to emp1

*pointer1 = &pointer0; //point pointer1 to wherever pointer1 is
pointing to

(*pointer1)->next = &emp2; //use pointer1 to set next of emp1 to point
to emp2

(*pointer1)->num = 5; //use pointer 1 to set emp1's num to 5

return ;
}


jagguy wrote:
hi
could someone tell me a good website that explains pointer to pointers well.
Not just simple stuff like 2d arrays passing , or pointing to another int
variab.le


May 31 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.