Skip to content

Instantly share code, notes, and snippets.

@willard1218
Created September 25, 2019 04:07
Show Gist options
  • Save willard1218/be6cb61d585d87b510ef603464e5957c to your computer and use it in GitHub Desktop.
Save willard1218/be6cb61d585d87b510ef603464e5957c to your computer and use it in GitHub Desktop.
printHexdump
void printHexdump( char *arr, int size) {
const unsigned int bytesOfType = sizeof( char);
const int numOfItemInRow = (0x10 / bytesOfType);
printf("=================================\n");
int count = 0;
for (int i = 0; i <= size / numOfItemInRow; i++) {
printf("%06x ", i);
for (int j = 0; j < numOfItemInRow && count < size; j++) {
printf("%02x ", 0xff & arr[count++]);
}
printf("\n");
}
printf("\n\n\n");
printf("array size : %d\n", size);
printf("total %d bytes\n",size * bytesOfType);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment