String Array on Esp32

String Array on Esp32

I need to implement a string array, like:

String[] txt = {"some text1", "some text2", "some text3", "some text4"};

The standard char[] doesn't suit me. How can I use string Array or List in Arduino IDE for ESP32?

1 Answer

You're free to use all STL facilities, including an array of strings. Standard caveats apply (dynamic RAM allocation from heap, STL uses lots of Flash for code, etc)

#include <string>
#include <array>

std::array<std::string> my_array = {"text1", "text2"};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.