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;
}
strtollets you specify the base (16, for hexadecimal, or 0 to auto-detect based on the0xprefix in the input) when parsing the string. Once you have the pointer stored as an integer, just usereinterpret_castto form the pointer.