[ create a new paste ] login | about

Link: http://codepad.org/mSt6mIP0    [ raw code | output | fork ]

C, pasted on Apr 9:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdlib.h>

void printBits(int x) {
   int n;
   for(n=0; n<8; n++) {
      if (0 != (x & 0x80)) { printf("1"); }
      else { printf("0"); }
      x = x<<1;
   }
}

int main() {
    char* name = "Marta";
    int i;
    for (i=0; i<5; i++) {
        printBits((int)name[i]);
        printf(" ");
    }
    return 0;
}


Output:
1
01001101 01100001 01110010 01110100 01100001 


Create a new paste based on this one


Comments: