Suppose I have the memory address as a string representation (say "0x27cd10"). How can I convert this to a pointer (void*)?
i.e.
int main() {
     const char* address = "0x29cd10";
     void* p;
     // I want p to point to address 0x29cd10 now...
     return 0;
}
                strtol lets you specify the base (16, for hexadecimal, or 0 to auto-detect based on the 0x prefix in the input) when parsing the string.  Once you have the pointer stored as an integer, just use reinterpret_cast to form the pointer.
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