Best way to build "string"

In your case Strings are completely safe and free from fragmentation just add an enclosing block { }

Strings are very very safe on small memory AVR boards. Using reserve() and String& avoids memory problems
Even if you run Out of Memory, the Uno/Meg2560 just keeps running with the Strings holding as much as they can. This makes it very easy to debug as there is not 'crash' and you can still see your debug print() output.

See my tutorial on Taming Arduino Strings for the details.

2 Likes