BYTE*
is probably a typedef for unsigned char*
, but I can't say for sure. It would help if you tell us what BYTE
is.
If BYTE* is unsigned char*, you can convert it to an std::string using the std::string range constructor, which will take two generic Iterators.
const BYTE* str1 = reinterpret_cast<const BYTE*> ("Hello World");
int len = strlen(reinterpret_cast<const char*>(str1));
std::string str2(str1, str1 + len);
That being said, are you sure this is a good idea? If BYTE
is unsigned char
it may contain non-ASCII characters, which can include NULLs. This will make strlen
give an incorrect length.