26 lines
622 B
C++
26 lines
622 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
int main(){
|
|
// you can extract the address from a variable like this
|
|
int varry = 100;
|
|
cout << "here's the address of the variable varry: ";
|
|
cout << &varry << endl;
|
|
|
|
// you can even take that address and put it in a pointer variable
|
|
int* pointy;
|
|
|
|
pointy = &varry;
|
|
|
|
cout << "this is the address inside the pointer variable pointy: ";
|
|
cout << pointy << endl; // this should be the same as above
|
|
|
|
cout << "The value inside varry: " << varry << endl;
|
|
|
|
*pointy = 200;
|
|
|
|
cout << "The value inside varry after setting it with *pointy = 200: " << varry << endl;
|
|
|
|
|
|
}
|