I'm still learning c++ and have spent hours trying to figure out a way to get a byte stored at a certain memory address, in my case ALL (well, almost all) memory addresses aren't dynamic - so addresses pointing to, for example variables will not change.
So I'm trying to retrieve a single byte stored at a known memory address.
For example let's say: 0x20000
the byte i'm trying to retrieve is, for example, let's say 0xEF
.
Now how would i retrieve the byte without using the dereference operator?
So basically i need to get 0xEF
without having to declare what type of data type it is, like literally just physically get the byte 0xEF
.
Hopefully this makes sense, I'm quite a noob :/
Now how would i retrieve the byte without using the dereference operator?
You cannot do this without dereferencing the accessed address. The smallest data type you can address is a char
. For bytes there's usually a typedef unsigned char uint8_t
used.
So you have to access the memory address using a reinterpret_cast<uint8_t*>(addr)
and dereference to get the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With