Created
February 1, 2016 02:16
-
-
Save henryscala/61a6fa2dd7f8de23b43d to your computer and use it in GitHub Desktop.
a c function to dump the buffer in hex
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> | |
char hexstr[]="0123456789ABCDEF"; | |
void hexdump(char* buf, int len) { | |
int i; | |
for(i=0;i<len;++i) { | |
int hi=(buf[i] >> 4) & 0x0f; | |
int lo=(buf[i] & 0x0f); | |
printf("%c%c,",hexstr[hi],hexstr[lo]); | |
} | |
printf("\n"); | |
} | |
int main() | |
{ | |
char buf[100]; | |
hexdump(buf,100); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment