/* Example of passing SafeString to a method and returning an updated SafeString result by Matthew Ford Copyright(c)2020 Forward Computing and Control Pty. Ltd. This example code is in the public domain. install the SafeString library from the Arduino Library manager or download and install the SafeString zip file from www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html */ #include "SafeString.h" int count = 0; void setup() { Serial.begin(9600); for (int i = 10; i > 0; i--) { Serial.print(' '); Serial.print(i); delay(500); } Serial.println(); Serial.println(F("This 'correct' example updates a SafeString with the current loop count.")); } // define a method to update a SafeString void loopCountStr(int num, SafeString& str) { str = "loop count = "; str += num; // update it // str returned via SafeString& arg } void loop() { count = 1; createSafeString(strRtn, 40, ); // create a SafeString for the return loopCountStr(count, strRtn); // update it Serial.println(strRtn); // print it Serial.println(F(" Finished")); while (1) { } // stop here }