fluffy

Network Archaeology tools for Unix
git clone https://git.woozle.org/neale/fluffy.git

Neale Pickett  ·  2017-08-08

hex.c

 1#include <stdio.h>
 2
 3int
 4main(int argc, char *argv[])
 5{
 6	size_t count;
 7
 8	for (count = 0; ; count += 1) {
 9		int c = getchar();
10
11		if (EOF == c) {
12			break;
13		}
14
15		if (count) {
16			putchar(' ');
17			if (0 == count % 8) {
18				putchar(' ');
19			}
20		}
21
22		printf("%02x", c);
23	}
24	putchar('\n');
25
26	return 0;
27}