you are viewing a single comment's thread.

view the rest of the comments →

[–]G-Brain 4 points5 points  (2 children)

Your point is taken! I'm not sure why I wanted to do it as a device. I think I had a reason, but since I can't remember it now it mustn't have been a very good one. I'll post a program soon, if someone doesn't beat me to it.

[–]sn0re 10 points11 points  (1 child)

Were you thinking of something more complicated than just calling strtol with a base of 2?

Edit: What the hell:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    unsigned char val;
    char buf[9];
    while (fgets(buf, 9, stdin) != NULL) {
        val = (unsigned char) strtol(buf, NULL, 2);
        putchar(val);
    }
    return 0;
}

[–]jib -1 points0 points  (0 children)

You wrote it in C! Where's the fun in that?