I\'m writing a function to print bits in c, I\'m only allowed to use write function. my function doesn\'t work for other numbers.
write
void print_bit
I have re-written the code from Is there a printf converter to print in binary format?
void print_bits(unsigned char octet) { int z = 128, oct = octet; while (z > 0) { if (oct & z) write(1, "1", 1); else write(1, "0", 1); z >>= 1; } }