Hello!
I want to work with individual bytes of integers. I know that ints are
32-bit and will always be. Sometimes I want to work with the entire
32-bits, and other times I want to modify just the first 8-bits for
example. For me, I think it would be best if I can declare the 32-bits
like this:
unsigned char bits[4];
When I want to treat this as a 32-bits integer, can I do something
like this?
unsigned int bits32 = *((unsigned int*)bits);
I'm unsure of the syntax. I don't need to work in-place so to speak. It is
fine to work with a copy.
Thanks in advance!
--
Daniel
I want to work with individual bytes of integers. I know that ints are
32-bit and will always be. Sometimes I want to work with the entire
32-bits, and other times I want to modify just the first 8-bits for
example. For me, I think it would be best if I can declare the 32-bits
like this:
unsigned char bits[4];
When I want to treat this as a 32-bits integer, can I do something
like this?
unsigned int bits32 = *((unsigned int*)bits);
I'm unsure of the syntax. I don't need to work in-place so to speak. It is
fine to work with a copy.
Thanks in advance!
--
Daniel
Comment