CSC-4730 / Lab_Examples / address_space_ex.cpp
address_space_ex.cpp
Raw
//Visualize the address space.
//Take note of the ASR, address space randomization.
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int i;
    int * p = (int *) malloc(sizeof(int));
    cout << "Address of main: " << hex << (void *) main << endl;
    cout << "Address of something on heap: " << hex << p << endl;
    cout << "Address of local var (stack): " << hex << &i << endl;

    return 0;
}