Skip to content

Instantly share code, notes, and snippets.

void hexdump(unsigned char *data, size_t size) {
char ascii[17] = {0};
size_t i;
for (i = 0; i < size; ++i) {
unsigned char c = data[i];
size_t next = i+1;
printf("%02X ", c);
ascii[i % 16] = isprint(c) ? c : '.';
if (next % 8 == 0 || next == size) {