Last active
September 30, 2015 18:48
-
-
Save kalloc/1845640 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
char raw[] = "\x0d\x0a\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"; | |
void hexdump(char *ptr, int len, int width) { | |
int count = 1; | |
printf("--------------------\n"); | |
for(;len>0;len--,ptr++,count++) { | |
printf("%02X", (unsigned char)ptr[0]); | |
if (count==width) { | |
count = 0; | |
printf("\n"); | |
} else { | |
printf(" "); | |
} | |
} | |
printf("\n"); | |
printf("--------------------\n"); | |
} | |
int main() { | |
hexdump(raw, sizeof(raw), 8); | |
} |
Author
kalloc
commented
Feb 16, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment