Created
September 25, 2019 04:07
-
-
Save willard1218/be6cb61d585d87b510ef603464e5957c to your computer and use it in GitHub Desktop.
printHexdump
This file contains hidden or 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
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