kandr

exercises from K&R
git clone git://bvnf.space/kandr.git
Log | Files | Refs

printf_binary.c (217B)


      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
#include <stdio.h>

void bp(char n){
    /* prints chars up to value 255 (for 255, the MSB is 2^7 == 128) */
    int i = 128;
    while (i) {
        printf("%c", ((n & i) == i) ? '1' : '0');
        i >>= 1;
    }
}