What does it mean to convert an integer value to a void*
or viceversa from a memory point of view?
My understanding is void*
is an address to a blo
This is quite like comparing apples and oranges. The only way that this code works is because you are explicitly casting it back and forth.
The C compiler is just copying the bytes from the int into the space for the pointer and back, just like how you can hold a char in an int.
This could even cause your number to be messed up if for some reason an 'int' is longer than a 'void *' on your platform.
If you actually do want have a number to convert from integers into pointers and back, look into intptr_t
. That type is actually designed to store both integers and pointers.