diff options
author | Malf Furious <m@lfurio.us> | 2018-10-10 02:00:44 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2018-10-10 02:00:44 -0400 |
commit | ad7743dfc1dc3f35a664545c827f362e45dbe073 (patch) | |
tree | a875aa4d3dfe71053087be77b48571be685bf512 /hexbin.c | |
parent | e8599c7e49e6374d022edeee639dd62004a4d0c1 (diff) | |
download | lib-des-gnux-ad7743dfc1dc3f35a664545c827f362e45dbe073.tar.gz lib-des-gnux-ad7743dfc1dc3f35a664545c827f362e45dbe073.zip |
Last time I'm writing this damn program
Diffstat (limited to '')
-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; +} |