Archived

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

vbisme

the **

Recommended Posts

vbisme    100
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
Facehat    696
** 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
Mezz    571
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   
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
ImmaGNUman    122
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
vbisme    100
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