I’m writing an emulator in C. Its memory is byte-addressible so I’m using a char array, but I need to read/write unaligned 32-bit integers.
Currently I’m using *((unsigned int*) &memory[address]), but it seems pretty horrible. What’s the best way to do it?
You can use
memcpy()directly. For example: