I\'m trying to store the value of an address in a non pointer int variable, when I try to convert it I get the compile error \"invalid conversion from \'int*\' to \'int\'\" this
int
may not be large enough to store a pointer.
You should be using intptr_t
. This is an integer type that is explicitly large enough to hold any pointer.
intptr_t thatvalue = 1;
// stuff
thatvalue = reinterpret_cast(ip);
// Convert it as a bit pattern.
// It is valid and converting it back to a pointer is also OK
// But if you modify it all bets are off (you need to be very careful).