I could not fully understand the consequences of what I read here: Casting an int pointer to a char ptr and vice versa
In short, would this work?
set
In addition to the endian issue, which has already been mentioned here:
CHAR_BIT
- the number of bits per char
- should also be considered.
It is 8 on most platforms, where for (int i=0; i<4; i++)
should work fine.
A safer way of doing it would be for (int i=0; i
Alternatively, you can include
and use for (int i=0; i<32/CHAR_BIT; i++)
.