Example 2: deference and address operator

In this code example the memory address of the variable b is output.

#include <iostream>
using namespace std;

int main() {
    int* a;
    int b = 10;


    // a now points to the memory address of b
    a = &b;

    // print memory adress of a
    cout << "memory adress: " << a << endl;
    
    // print value of a
    cout << "value: " << *a << endl;

    return 0;
}
Output
memory adress: 0x7ffee470a94c
value: 10