What is the best way to go about converting a 4-byte integer into a char array such that each element of the array contains a byte from the integer?
For example: I have an integer, 56, which looks like this in memory: 0x00 0x00 0x00 0x38. I want to convert that integer to an array of chars, with array = 0x00 ... array = 0x38.
I've tried memcpy() to copy the memory directly from the integer, and it works to an extent, but it doesn't seem to like int values over 128 (max size for a char), which makes me think that memcpy() is trying to copy the entire int into the first element of the array, which is obviously not what I want.
I've also tried using a char pointer to access each byte of the integer individually, but I get the same problem.