- #include <stdio.h>
- #include <assert.h>
- #include <stdlib.h>
- #include <inttypes.h>
- //http://androidxref.com/7.1.1_r6/xref/external/avahi/avahi-compat-howl/text-test.c#33
- static void hexdump(const void* p, size_t size) {
- const uint8_t *c = p;
- assert(p);
- printf("Dumping %u bytes from %p:\n", size, p);
- while (size > 0) {
- unsigned i;
- for (i = 0; i < 16; i++) {
- if (i < size)
- printf("%02x ", c[i]);
- else
- printf(" ");
- }
- for (i = 0; i < 16; i++) {
- if (i < size)
- printf("%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.');
- else
- printf(" ");
- }
- printf("\n");
- c += 16;
- if (size <= 16)
- break;
- size -= 16;
- }
- }
linux c中的hexdump实现,用于打印内存
猜你喜欢
转载自blog.csdn.net/qq_36195711/article/details/77100296
今日推荐
周排行