#include <stdio.h>
// 内存查看
void hexDump(const unsigned char *data, size_t size)
{
int i;
size_t offset = 0;
while (offset < size)
{
printf("%04x ", offset);
for (i=0; i<16; i++)
{
if (i%8 == 0) putchar(' ');
if (offset+i < size)
{
printf("%02x ", data[offset + i]);
}
else
{
printf(" ");
}
}
printf(" ");
for (i=0; i<16 && offset+i<size; i++)
{
if (isprint(data[offset+i]))
{
printf("%c", data[offset+i]);
}
else
{
putchar('.');
}
}
putchar('\n');
offset += 16;
}
}
C语言 HexDump
最新推荐文章于 2022-08-29 08:44:54 发布