From ad7743dfc1dc3f35a664545c827f362e45dbe073 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 10 Oct 2018 02:00:44 -0400 Subject: Last time I'm writing this damn program --- hexbin.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 hexbin.c (limited to 'hexbin.c') 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 +#include + +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; +} -- cgit v1.2.3