I have been googling a lot on this and have been reading a lot, but still I am not quite understanding it. I hope someone here could cite me a sample with detail explanation.
What is "reinterpretation of memory"?
Let say I have:
char *myChar;
int myInt = 5;
//Or
float myFloat = 5.5;
And I would like to change myChar
so it points to, let say, an int
or float
like the above.
How could I make use of "reinterpretation of memory" to make this work so that myChar
can point to either myInt
or myFloat
?
Again, what does "reinterpretation of memory" mean?
Edit:
What I really want to do is instead of casting either int
or float
to char
pointer, but to actually change myChar
to be of type int
or float
pointing to either myInt
or myFloat
.
I.e.:
<cast?> myChar = &myInt; //or &MyFloat;