Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void DumpHex(const char *p, int size)
  4. {
  5.     int left = size;
  6.     while(left > 0)
  7.     {
  8.         int i;
  9.         for(i = 0; i < 16; i++)
  10.         {
  11.             printf("%2.2X ", *p++);
  12.             left--;
  13.             if(left <= 0)
  14.                 break;
  15.         }
  16.         printf("\n");
  17.     }
  18. }
  19.  
  20. int main()
  21. {
  22.     char testdat[] = "\x42\x23\x09\x00\x63\x12\x22";
  23.     char testdat2[] = "Something longer than 16 bytes to see wrapping. Blah Blah Blah";
  24.  
  25.     printf("testdat:\n");
  26.     DumpHex(testdat, sizeof(testdat)-1);
  27.     printf("testdat2:\n");
  28.     DumpHex(testdat2, sizeof(testdat2)-1);
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement