An Arduino stack based fixed string class:
#include <FixedString.h>
//To reliably use a raw stack based string buffer
//Replace:
char buffer[24];
strcpy(buffer,"This is my");
strcat(buffer," string");
Serial.println(buffer);
//With:
FixedString<24> buffer="This is my";
buffer+=" string";
Serial.println(buffer.c_str());
//OR if the maximum string size used is known:
//Replace:
String s;
s+="Some stuff";
s+="some other stuff";
s+=2300;
Serial.println(s.c_str());
//With:
FixedString<48> s;
s+="Some stuff";
s+="some other stuff";
s+=2300;
Serial.println(s.c_str());
//OR where formatting needed:
FixedString<64> s;
s.format("Testing format: int: %i, long: %li", 10, 75000l);
Serial.println(s.c_str());
s.format(F("Testing flash format: int: %i, long: %li"), 10, 75000l);
Serial.println(s.c_str());
Copyright (c) 2022 Fatlab Software.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA