Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int i = 5;
- int *p = &i; /* &i = address of variable i, p = address of i, *p = 5 */
- cout << p << " this is the pointer\n";
- cout << &p << " address of pointer I think\n";
- cout << &i << " address of i\n";
- cout << *p << " Lastly, this is the value (not address part) of the pointer p itself (AKA *p).";
- //cout << p = address
- //cout << &i = address
- //cout << *p = number
- //cout << i = number obviously
- //p by itself just returns the address of int i whereas
- //*p is digging into the address of where the value stored into i lives
- //(its address) and retreives it thus bringing
- //back a number from the address cell.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement