Jump to content
  • Advertisement

Archived

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

the **

This topic is 6509 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok... int myInt = 5; int *pmyInt = &myInt; if you return pmyInt it gives the address of the variable myInt and *pmyInt gives the value of myInt which is 5. What the hell is int **psomething ??? int myInt = 5; int *pmyInt = &myInt; int **ppmyInt = &pmyInt; *ppmyInt return the address of pmyInt and **ppmyInt the value or what?

Share this post


Link to post
Share on other sites
Advertisement
** means "a pointer to a pointer" (yep, its possible since pointers are really just variables that contain an offset).

So **ppmyInt should give you the value of myInt since your just dereferencing it like so: ppmyint->pmyint->myInt.

Brain hurt yet?

----------------------------------------
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant and she fell on me? Then it wouldn't seem quite so funny.

Edited by - The Senshi on July 24, 2000 4:28:38 PM

Share this post


Link to post
Share on other sites
Well, *ppmyInt will return myInt''s address, not the address of pmyInt.

Yes, **ppmyInt will return the value in myInt.

-Mezz

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Something is a Something
Something *p is a pointer to a Something.
Something **pp is a pointer to a pointer to a Something.
etc.

In your example *ppmyInt is a pointer to your int.
**ppmyInt is the int itself.

int myInt = 5; // The value of myInt is 5
int *pmyInt = &myInt; // The value of pmyInt is the address of myInt
int *ppmyInt = &pmyInt; // The value of ppmyInt is the address of pmyInt

*ppmyInt is not the address of pmyInt, it''s the value of pmyInt (the value of the pointer not the int).

Share this post


Link to post
Share on other sites
that''s not confusing! this is: ****************p

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

Share this post


Link to post
Share on other sites
check it out......!!!

#include

int main()
{
int myInt = 5;
int * pmyInt = &myInt;
int ** ppmyInt = &pmyInt;

cout << "myInt: " << myInt << "\n";
cout << "&myInt: " << &myInt << "\n";
cout << "pmyInt: " << pmyInt << "\n";
cout << "&pmyInt: " << &pmyInt << "\n";
cout << "*pmyInt: " << *pmyInt << "\n";
cout << "ppmyInt: " << ppmyInt << "\n";
cout << "&ppmyInt: " << &ppmyInt << "\n";
cout << "*ppmyInt: " << *ppmyInt << "\n";
cout << "**ppmyInt: " << **ppmyInt << "\n";

return (0);
}

OUTPUT:
myInt: 5
&myInt: 0x0065FDF4
pmyInt: 0x0065FDF4
&pmyInt: 0x0065FDF0
*pmyInt: 5
ppmyInt: 0x0065FDF0
&ppmyInt: 0x0065FDEC
*ppmyInt: 0x0065FDF4
**ppmyInt: 5

eh? how''s that! good way to answer a question yourself.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!