直接上代码
所需头文件 :
1 std::string ByteStream2String(const uint8_t *pByteStream, size_t iStreamLen)
2 {
3 std::string sRet = "";
4 char curr_byte[3];
5
6 for (size_t idx = 0; idx < iStreamLen; ++idx)
7 {
8 memset(curr_byte, 0, 3);
9 sprintf_s(curr_byte, "%02hhX", pByteStream[idx]);
10
11 sRet += curr_byte;
12 sRet += " ";
13 }
14
15 return sRet;
16 }
测试如下
运行结果如下
以上, 如有错误疏漏, 欢迎指正
原文链接: https://www.cnblogs.com/TssiNG-Z/p/13857124.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/204264
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!