How to get data from a memory address stored as an int?

Viewed 73

Is it possible to get the data from a memory address stored as an int?

I'm trying to access the data from a memory address stored as an int. Im then trying to read the data from outside the scope, which i am unsure how to do.

For example:

unsigned int addr;
unsigned int bytes;

template<typename t>
void my_func(t arg)
{
    t* local_args = new t;
    *local_args = arg;
    bytes = sizeof(local_args);
    addr = reinterpret_cast<unsigned int>(&local_args);
}


int main()
{
    my_func(5608430536);

    // doesnt work but explains what im trying to do:
    auto i = *reinterpret_cast<char[bytes]*>(addr);
}
0 Answers
Related