c++以16进制输出字符串

char* pData = "hello world";
char buf[3];
std::string result = "";
for (int i = 0;i < length; i++)
{
    sprintf(buf, "%02x", pData[i]);
    result += buf;
}
printf("%s", result);
原文地址:https://www.cnblogs.com/sherlock-merlin/p/12870624.html