Arduino Serial / Streams concatenate things for you. Doing it yourself is inefficient and less stable.
As simple as it is, if you get out of the habit of doing this sort of thing, it'll generally improve your Arduino project code. Some of these patterns that are quite normal on desktop are not a good fit for a small microcontroller like a AVR that is in the Arduino UNO, Arduino Nano, etc.
But the same thing applies to at a slightly larger scale with something like an ESP8266 or ESP32 and trying to cobble together entire webpages in a single String variable instead of just printing the individual parts to the WiFiClient stream, letting the buffering concatenate things naturally for you. Generally you can get away with it on very small bits of code, like examples. But it should not be your default way of doing it.
0:00 The Basic Idea
0:29 Three Quick Notes
0:59 Why?
1:09 Dynamic Allocation
3:29 Not Dynamically Allocating
4:14 Code Bloat
4:36 Tests
6:38 Results
7:47 Larger Microcontroller Systems
8:17 Aesthetics
9:29 The Main Thing
9:40 Outro
#arduino #tip #serial #uart