#include <string>
#include <sstream>
#include <iomanip>
#include <iostream>
void create_hex_str(uint8_t *data, int len, std::string &tgt)
{
std::stringstream ss;
ss << std::hex << std::setfill('0');
ss << "\n";
for (int i=0; i<len; i++)
{
ss << std::setw(2) << static_cast<unsigned>(data[i]) << " ";
}
tgt = ss.str();
}
int main()
{
/* char buf[] = {
0x2,
0x0,
0x3,
0x3,
0x0,
0x0,
0x6,
0x4,
0x0,
0x2,
0x0,
0x0
}; */
char *buf = new char[12];
buf[0] = 0x2;
buf[1] = 0x0;
buf[2] = 0x3;
buf[3] = 0x3;
buf[4] = 0x0;
buf[5] = 0x0;
buf[6] = 0x6;
buf[7] = 0x4;
buf[8] = 0x0;
buf[9] = 0x2;
buf[10] =0x0;
buf[11] =0x0;
std::string hex_string;
create_hex_str((uint8_t*)buf, 12, hex_string);
std::cout << hex_string;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxpb21hbmlwPgojaW5jbHVkZSA8aW9zdHJlYW0+Cgp2b2lkIGNyZWF0ZV9oZXhfc3RyKHVpbnQ4X3QgKmRhdGEsIGludCBsZW4sIHN0ZDo6c3RyaW5nICZ0Z3QpCnsKICAgIHN0ZDo6c3RyaW5nc3RyZWFtIHNzOwogICAgc3MgPDwgc3RkOjpoZXggPDwgc3RkOjpzZXRmaWxsKCcwJyk7CiAgICBzcyA8PCAiXG4iOwogICAgZm9yIChpbnQgaT0wOyBpPGxlbjsgaSsrKQogICAgewogICAgICAgIHNzIDw8IHN0ZDo6c2V0dygyKSA8PCBzdGF0aWNfY2FzdDx1bnNpZ25lZD4oZGF0YVtpXSkgPDwgIiAiOyAgICAgICAgCiAgICB9CiAgICB0Z3QgPSBzcy5zdHIoKTsKfQoKaW50IG1haW4oKQp7CiAgICAvKiBjaGFyIGJ1ZltdID0gewogICAgICAgIDB4MiwKICAgICAgICAweDAsCiAgICAgICAgMHgzLAogICAgICAgIDB4MywKICAgICAgICAweDAsCi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