String objects have a member function .c_str()
that returns const char*
. This pointer can be attributed to const uint8_t*
:
std::string name("sth"); const uint8_t* p = reinterpret_cast<const uint8_t*>(name.c_str());
Please note that this pointer will only be valid until the original string object is modified or destroyed.
source share