I\'m trying to simply convert a byte received from fget into binary.
I know the value of the first byte was 49 based on printing the value. I now need to convert this in
One way, among many:
#include #include int main(void) { int i; char bits[CHAR_BIT + 1]; unsigned char value = 47; for (i = CHAR_BIT - 1; i >= 0; i -= 1) { bits[i] = '0' + (value & 0x01); value >>= 1; } bits[CHAR_BIT] = 0; puts(bits); return 0; }