You can also do it like this:
std::string adr = "0x7fff40602780"; unsigned long b = stoul(address, nullptr, 16); int *ptr = reinterpret_cast<int*>(b);
If you want to convert a string address to an object pointer, here is another example:
std::string adr= "0x7fff40602780"; unsigned long b= stoul(adr, nullptr, 16); unsigned long *ptr = reinterpret_cast<unsigned long*>(b); Example *converted = reinterpret_cast<Example*>(ptr);
source share