Convert std::string to String

You can get the std::string’s C-string (const char* via calling c_str() on the object, then feed that in the constructor of String. This will cause double memory usage, String will copy it into a newly allocated buffer. (Henc why equalization is kinda important).

std:string cpp_str = "Hello";
String ard_str = String(cpp_str.c_str());
1 Like