I want to convert an unsigned int and break it into 2 chars. For example: If the integer is 1, its binary representation would be 0000 0001. I want the 0000 part in one char variable and the 0001 part in another binary variable. How do I achieve this in C?
Share
If you insist that you have a
sizeof(int)==2then:If you have eight bits total (one byte) and you are breaking it into two 4-bit values: