Please tell me how do I print a bit, like printf(\"%d\",bit);.
printf(\"%d\",bit);
To print the m-th bit (m from 1..16 or 32) of n:
void print_bit(n, m) { printf("%d", n & (1 << (m - 1))); }
Remove the - 1 bit if your bit counter starts at 0.
- 1