#include <iostream>
#include <sstream>
typedef unsigned char byte_t;
std::string byte_to_str(byte_t const *p, size_t Size)
{
std::stringstream str;
size_t const BuffSize = 10;
char Buff[BuffSize];
for (size_t i = 0; i < Size; ++i)
{
sprintf_s(Buff, BuffSize, "0x%.2lx", p[i]);
str << Buff;
if (i != (Size - 1))
{
str << " ";
}
}
return (str.str());
}
int main()
{
byte_t Buffer[] = {0x10, 0xef, 0x2, 0x6b, 0xcd, 0x9a};
std::cout << byte_to_str(Buffer, sizeof (Buffer)) << std::endl;
return 0;
}