Question: I have defined a pointer address for window

```
#ifdef _WIN64 

    typedef uint64_t unit_pointer;

#   define PRINTF_PTR "%I64x"

#else

    typedef unsigned long unit_pointer;

#   define PRINTF_PTR "%lx"

#endif

TEST *obj = &test_obj;

char obj_pointer_add[50]; 

sprintf(obj_pointer_add, PRINTF_PTR, (unit_pointer)obj);

```

Now i want to recreate the obj pointer in other place, given that i know obj\_pointer\_add.
How could i convert back obj\_pointer\_add to unit\_pointer? 

```
unit_pointer point_address= (unit_pointer)obj_pointer_add; (ERROR CONVERTING)

TEST *new_obj = reinterpret_cast<TEST *>(point_address); (fail because of pointer_address wrong)

```

Thanks

Answer: 
I really have no idea why you need this. But, I suggest you this easier way (IMO) to get rid of those `"#if / #endif"` :

```
TEST *obj = new TEST();

std::stringstream stream;                //
stream << std::hex << obj;               //Convert address to a hex-string
std::string hex_str_addr(stream.str());  //

// ...

std::uintptr_t addr;
std::stringstream(hex_str_addr) >> std::hex >> addr; //Convert back to a address

TEST *new_obj = reinterpret_cast<TEST*>(addr);

```

Use `uintptr_t` which is aware of your system pointer size.
You could `sscanf` it, using the same format, into a variable.

**Note:** You can **only** do this in the *exact* same process. So if you store the pointer and restart your program, you can not use the stored pointer again. And if you use it to pass around pointer in the same process, why would you want it as a string, instead of using the actual pointer?