Your plan doesn't sound like it's going to work, since a valid memory address in one process might be an invalid memory address in another process... Nevertheless, here is how you can do it:
- In the first process, call
sprintf(str,"%p",ptr)
- In the second process, call
sscanf(str,"%p",&ptr)
- On a 32-bit system, you'll need to declare
char str[8+1]
- On a 64-bit system, you'll need to declare
char str[16+1]
Having said that, you probably need to send the contents of the memory address, or if too long for this purpose, then write them into a file in one process and read them from that file in the other process.