#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <Windows.h>
#include "log.h"
void dump(unsigned char * buff,int len)
{
char szTmp[4] = {0};
char szLog[1024] = {0};
for (int i=0;i<len;i++)
{
ZeroMemory(szTmp,4);
sprintf_s(szTmp,4,"%02X",buff[i]);
strcat_s(szLog,1024,szTmp);
strcat_s(szLog,1024," ");
}
strcat_s(szLog,1024,"\n");
printf(szLog);
}
int _tmain(int argc, _TCHAR* argv[])
{
char szLog[64] = {0};
//strcpy_s(szLog,64,"ABCDEF");
strcpy_s(szLog,64,"abcdef");
dump((unsigned char*)szLog,6);
return 0;
}
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <Windows.h>
#include "log.h"
void dump(unsigned char * buff,int len)
{
char szTmp[4] = {0};
char szLog[1024] = {0};
for (int i=0;i<len;i++)
{
ZeroMemory(szTmp,4);
sprintf_s(szTmp,4,"%02X",buff[i]);
strcat_s(szLog,1024,szTmp);
strcat_s(szLog,1024," ");
}
strcat_s(szLog,1024,"\n");
printf(szLog);
}
int _tmain(int argc, _TCHAR* argv[])
{
char szLog[64] = {0};
//strcpy_s(szLog,64,"ABCDEF");
strcpy_s(szLog,64,"abcdef");
dump((unsigned char*)szLog,6);
return 0;
}
本文介绍了一个使用C语言编写的简单程序,该程序能够将输入的字符串转换为对应的十六进制表示形式,并通过示例展示了如何进行字符数组的处理及格式化输出。

被折叠的 条评论
为什么被折叠?



