That's funny, because my perspective is that in a highly memory constrained environment C-strings are in fact easier to manage in tightly controlled and predictable memory footprints while String objects are much more likely to get away from you with unpredictable memory footprints and catastrophic misbehaviour when memory fills up.
no indication in this post that there is any memory constraint the requires forgoing the inherent safety of Strings
on Uno and Mega2560 Strings are essentially bullet proof in the face of out-of-memory. Check out my link above for the examples. Taming Arduino Strings shows how to control/monitor String memory usage in general.
Finally if do you want to use fixed size char[]s then check out my SafeString library (detailed tutorial here) that wraps up the low level c-string methods with error checks that protect your code from going boom and gives you very clear debug messages, including the name of the offending variable, so you can fix the problems.
As each new micro adds more and more memory, the argument based on memory constraints becomes less and less valid.
drmpf:
As each new micro adds more and more memory
Yeah, some do. But the ATMega328 remains the foundation of 99% of what "Arduino" means, and it is pretty restricted. Personally, I mainly write code for the ATTiny and Strings are next to impossible.
drmpf:
As each new micro adds more and more memory, the argument based on memory constraints becomes less and less valid.
So, more memory means sloppy programming is OK?
If one is using the Arduino to learn C++, then they should simply learn the C++ way to do strings.
If you (or your employer) expects your programs to be readable by others or transportable into other platforms, then they should simply learn the C++ way to do strings.
In that case I completely agree, Strings are not suitable. In fact even C has problems, I found I needed to use ASM because C was using extra code saving a lot of registers for each fn call that did not need to be saved.
Strings with a capital S, The class C++ added 20 years ago to overcome the systemic coding errors arising from using c-string methods. Microsoft has banned c-string methods and recommends Strings for C++ coding.
drmpf:
Strings with a capital S, The class C++ added 20 years ago to overcome the systemic coding errors arising from using c-string methods. Microsoft has banned c-string methods and recommends Strings for C++ coding.
When Microsoft comes with advises I choose not to follow them.
Strings and Arduino is a very bad mix. "Looking for trouble? Use Strings".
I avoid Strings in all my arduino-code. I used it before since it makes thing easy. My experience is that after a few weeks, the controller start to fail (not stop completely). After I removed the Strings things worked OK.
I learned this by reading postings from other users here, who also warned about using Strings in arduino code.
My experience is that after a few weeks, the controller start to fail (not stop completely).
I would be interested in the String version of you code, if you can make it available. I think Taming Arduino Strings covers all the problems, but would like to check that I have not missed something.