diff options
Diffstat (limited to 'hexbin.c')
-rw-r--r-- | hexbin.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/hexbin.c b/hexbin.c new file mode 100644 index 0000000..d312438 --- /dev/null +++ b/hexbin.c @@ -0,0 +1,28 @@ +/* + * hexbin.c + * + * This program takes no arguments, it simply interprets its input as hex + * and outputs bytes. + */ + +#include <stdio.h> +#include <stdint.h> + +int main() +{ + uint8_t b; + char ip[3] = {0}; + + while (1) + { + fread(ip, 1, 2, stdin); + + if (feof(stdin)) + break; + + sscanf(ip, "%hhx", &b); + fwrite(&b, 1, 1, stdout); + } + + return 0; +} |