C++ style cast from unsigned char * to const char *
char *
and const unsigned char *
are considered unrelated types. So you want to use reinterpret_cast
.
But if you were going from const unsigned char*
to a non const
type you'd need to use const_cast
first. reinterpret_cast
cannot cast away a const
or volatile
qualification.
Try reinterpret_cast
unsigned char *foo();
std::string str;
str.append(reinterpret_cast<const char*>(foo()));