Replacing all my char's with String fixed the problem but I suspect at a high Ram / Time cost.
If, by fixed, you mean masked, I'll accept that. The String class bring other (not entirely the fault of the String class) problems that have simply not yet bitten your derriere.
- Assign a value to a constant char[], the string is in a struct so I believe I need the * operator to make it behave like a pointer (I think)
The strcat() function can do that.
char conStg[24];
conStg[0] = '\0'; // "Empty" the buffer
strcat(conStg, "Some constant string");
- Assign a value to a char[] dynamically, I am reading it from an SD card char by char.
char buffer[80];
byte index = 0;
while(file.available())
{
if(index < 79)
{
buffer[index++] = file.read();
buffer[index] = '\0'; // Keep it NULL terminated
}
}
- Compare two char[]'s, the two above, my function accepts 1 as an argument and loops through an array of struct's and finds a match.
if(strcmp(conStg, buffer) == 0)
{
// The contents match
}
- This a little embarrassing smiley-red serial.print a char[] - Sorry but it wouldn't work, although that may have been something I was doing with it earlier.
This is #4, isn't it?
Serial.print("conStg = [");
Serial.print(conStg);
Serial.println("]");
This will print
conStg = [Some constant string]
on one line and move the cursor to the start of the next line.
Edit: Added the missing the " in the snippet under #4. Thanks to rockwallaby for catching that.