大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
void hexDump(const char* buf, int len)
{
if (len < 1 || buf == NULL) return;
const char *hexChars = "0123456789ABCDEF";
int i = 0;
char c = 0x00;
char str_print_able[17];
char str_hex_buffer[16 * 3 + 1];
for (i = 0; i < (len / 16) * 16; i += 16)
{
int j = 0;
for (j = 0; j < 16; j++)
{
c = buf[i + j];
// hex
int z = j * 3;
str_hex_buffer[z++] = hexChars[(c >> 4) & 0x0F];
str_hex_buffer[z++] = hexChars[c & 0x0F];
str_hex_buffer[z++] = (j < 10 && !((j + 1) % 8)) ? '_' : ' ';
// string with space repalced
if (c < 32 || c == '\0' || c == '\t' || c == '\r' || c == '\n' || c == '\b')
str_print_able[j] = '.';
else
str_print_able[j] = c;
}
str_hex_buffer[16 * 3] = 0x00;
str_print_able[j] = 0x00;
printf("%04x %s %s\n", i, str_hex_buffer, str_print_able);
}
// 处理剩下的不够16字节长度的部分
int leftSize = len % 16;
if (leftSize < 1) return;
int j = 0;
int pos = i;
for (; i < len; i++)
{
c = buf[i];
// hex
int z = j * 3;
str_hex_buffer[z++] = hexChars[(c >> 4) & 0x0F];
str_hex_buffer[z++] = hexChars[c & 0x0F];
str_hex_buffer[z++] = ' ';
// string with space repalced
if (c < 32 || c == '\0' || c == '\t' || c == '\r' || c == '\n' || c == '\b')
str_print_able[j] = '.';
else
str_print_able[j] = c;
j++;
}
str_hex_buffer[leftSize * 3] = 0x00;
str_print_able[j] = 0x00;
for (j = leftSize; j < 16; j++)
{
int z = j * 3;
str_hex_buffer[z++] = ' ';
str_hex_buffer[z++] = ' ';
str_hex_buffer[z++] = ' ';
}
str_hex_buffer[16 * 3] = 0x00;
printf("%04x %s %s\n", pos, str_hex_buffer, str_print_able);
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/190890.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...