我找到的简单方法:
string s( (char *) a);
详细的互相转换的测试代码:
char token[] = "fuck u";
uint8_t* potentialData = (uint8_t*) token;
cout << "Hello World!" << potentialData << endl;
string tis((char *)potentialData);
cout << tis << endl;
out:
Hello World!fuck u
fuck u
其他方法(来源:https://stackoverflow.com/questions/4508911/convert-uint8-t-to-stdstring-in-c)
std::string s( data, data+len );
其中len为data的长度