LuminaryJanitor
2[H]4U
- Joined
- Oct 26, 2005
- Messages
- 2,340
Is there a simpler way than the following code to force C to assign the same bit pattern to a different type? Casts between ints, chars and pointers seem to work like this, until you bring floats into the mix.
Could've sworn I saw a more straightforward way of going about it earlier today (at least, I'm pretty sure I understood the example I saw, and I only just got this void type puzzled out).
Code:
float f = 7.7;
int n = *(int *)(void *)&f;
Could've sworn I saw a more straightforward way of going about it earlier today (at least, I'm pretty sure I understood the example I saw, and I only just got this void type puzzled out).