fork download
  1. #include <ctype.h>
  2. #include <stdio.h>
  3.  
  4. void dumpdata(unsigned char *data, size_t bytes) {
  5. size_t lin;
  6. for (lin = 0; lin < bytes; lin += 16) {
  7. size_t col;
  8. printf("%08lX: ", (unsigned long)lin);
  9. for (col = 0; (col < 16) && (lin + col < bytes); col += 1) {
  10. printf("%02x ", data[lin + col]);
  11. }
  12. for (; col < 16; col += 1) {
  13. printf(" ");
  14. }
  15. printf("| ");
  16. for (col = 0; (col < 16) && (lin + col < bytes); col += 1) {
  17. if (isprint(data[lin + col])) {
  18. putchar(data[lin + col]);
  19. } else {
  20. putchar('.');
  21. }
  22. }
  23. putchar('\n');
  24. }
  25. }
  26.  
  27. int main(void) {
  28. char words[10][9] = {
  29. "Hello\n",
  30. "Good-bye"
  31. };
  32.  
  33. dumpdata((void*)words, sizeof words);
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 1676KB
stdin
Standard input is empty
stdout
00000000: 48 65 6c 6c 6f 0a 00 00 00 47 6f 6f 64 2d 62 79 | Hello....Good-by
00000010: 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | e...............
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
00000050: 00 00 00 00 00 00 00 00 00 00                   | ..........