I want to store a number of strings in an object. Currently I have:
class MyClass {
int numStrings = 0;
??? strings[20];
public:
void addString(const char str[]);
void print();
};
void MyClass::addString(const char str[]) {
strings[numStrings] = str;
numStrings++;
}
void MyClass::print() {
for (int i = 0 ; i < numStrings ; i++) {
Serial.println(strings[i]);
}
}
Serial.println()
works with strings in RAM and in PROGMEM alike.
Is there a type that I can give to my strings
variable that allows me to store both types of strings?
MyClass s;
s.addString("This should work");
s.addString(F("This should work, too"));