一、uint8_t转string
#include <iostream>
using namespace std;
int main() {
typedef uint8_t U8;
U8 Data[] = { 0x48, 0x65, 0x6C, 0x6C, 0x6F,0x2E };
std::string temp;
for (uint8_t i : Data)
{
temp += i;
}
std::cout << temp << std::endl;
std::string tempa="a";
temp=tempa+temp;
std::cout << temp << std::endl;
return 0;
}
二、string转char
#include <iostream>
using namespace std;
int main() {
typedef uint8_t U8;
U8 Data[] = { 0x48, 0x65, 0x6C, 0x6C, 0x6F,0x2E };
std::string temp;
for (uint8_t i : Data)
{
temp += i;
}
std::cout << temp << std::endl;
std::string tempa="a";
temp=tempa+temp;
std::cout << temp << std::endl;
const char* mlog_s=temp.c_str();
cout<<"a"<<mlog_s<<endl;
while(* mlog_s!=0)
{
printf("%02x ", *mlog_s);
mlog_s++;
}
return 0;
}