String Surgery
In cybersecurity situations, your project might need to modify a string it receives. One method for modifying strings is to create a larger string by adding smaller strings together. This process is called concatenation.
Example project: string_surgery_intro
- Enter and name string_surgery_intro.
- Click the Download button.
- Check the results in the serial terminal.
- Verify that it displays s = “Have a nice day.”
How string_surgery_intro Works
The project starts with 4 separate strings: s1, s2, s3, and s4, and adds them together. Addition with string objects is very different from the addition in the int and float objects you are probably familiar with. When string objects are added, they are combined. So, “abc” + “def” results in a string “abcdef”. In our case, set s to (s1 + s2 + s3 + s4) results in a new string variable s that refers to the “Have a nice day.” string.