#include #include #include #include #include void hexdump(void *ptr, size_t size) { unsigned char *p = ptr; unsigned char *end = p + size; char ascii[17]; size_t i; for (i = 0; i < 16; ++i) { ascii[i] = '\0'; } i = 0; while (p != end) { if (i % 16 == 0) { if (i != 0) { printf(" |%s|\n", ascii); } printf("%p ", p); } printf("%02X ", *p); if (*p >= ' ' && *p <= '~') { ascii[i % 16] = *p; } else { ascii[i % 16] = '.'; } ++p; ++i; } while (i % 16 != 0) { printf(" "); ++i; } printf(" |%s|\n", ascii); }