Created
July 17, 2018 21:26
-
-
Save abenson/0d2065e9f7819f346d7db5992108ee48 to your computer and use it in GitHub Desktop.
bin2chr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
int main(int argc, const char *argv[]) | |
{ | |
uint8_t b = 0, c = 128; | |
int i; | |
if(argv[1] == NULL) { | |
return 1; | |
} else if(strlen(argv[1]) != 8) { | |
return 2; | |
} | |
for(i=0; i<8; i++) { | |
if(argv[1][i] == '1') { | |
b |= c; | |
} | |
c = c >> 1; | |
} | |
printf("%c", b); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment