|
|
|
|
|
by jakobegger
4121 days ago
|
|
Yes. Use memcpy if you need to do this! This is especially important when you're on a platform that requires aligned pointers. For example, the following code will crash on ARM char bytes[5] = {0};
float flt = *(float*)&(bytes[1]);
Using memcpy works on any platform with 4 byte floats: char bytes[5] = {0};
float flt;
memcpy(&flt, &(bytes[1]), 4);
|
|
Embedded targets are always memory-constrained. If they aren't, you are wasting money on hardware.