【发布时间】:2017-07-16 00:19:45
【问题描述】:
这是我为 Print a byte array to hex String 编写的,但现在我想将它们保存为 std::string 并稍后使用
这是我的代码
typedef std::vector<unsigned char> bytes;
void printBytes(const bytes &in)
{
std::vector<unsigned char>::const_iterator from = in.begin();
std::vector<unsigned char>::const_iterator to = in.end();
for (; from != to; ++from) printf("%02X", *from);
}
我能做什么?,我想将它保存为字符串而不是在控制台窗口中打印(显示)? 任何想法!
【问题讨论】:
-
"在 C++ 中没有类似 StringBuilder 的函数" - 是的,有。它被称为
std::ostringstream。
标签: c++