How to convert Arduino String to std::string
If you have an Arduino String:
arduino_string_example.cpp
String arduinoStr = "test123";you can easily convert it to a std::string by using:
arduino_to_stdstring.cpp
std::string stdStr(arduinoStr.c_str(), arduinoStr.length());The std::string constructor will **copy the data,**therefore you can de-allocate the Arduino String instance safely.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow