Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void hexdump(char *buf, size_t length)
- {
- int star = 0;
- for (size_t i = 0; i < length; i += 16, buf += 16) {
- if (i && !memcmp(buf, buf - 16, 16)) {
- if (!star)
- puts("*");
- star = 1;
- continue;
- }
- star = 0;
- printf("%08zx ", i);
- for (size_t j = 0; j < 16; j++) {
- printf("%02x ", buf[j] & 0xff);
- if ((j & 7) == 7)
- putchar(' ');
- }
- putchar('|');
- for (size_t j = 0; j < 16; j++) {
- int c = buf[j];
- putchar(c >= ' ' && c <= '~' ? c : '.');
- }
- puts("|");
- }
- }
Add Comment
Please, Sign In to add comment