1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 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; }