String str = "A1N c2 t120 d4 t0 b5 t0 a2 t368 e2 t452 1c t0 e1 t600";
String strs[20];
void setup(void)
{
Serial.begin(115200);
delay(200);
Serial.println(str);
// Call the Split function to split the string into substrings
Split(str, ' ', strs, 20);
// Show the resulting substrings
for (int i = 0; i < 19; i++)
{
Serial.print(i);
Serial.print(": \"");
Serial.print(strs[i]);
Serial.println("\"");
}
Split("This is a test this is a longer test", ' ', strs, 20);
for (int i = 0; i < 19; i++)
{
Serial.print(i);
Serial.print(": \"");
Serial.print(strs[i]);
Serial.println("\"");
}
}
void Split(String input, char delimiter, String output[], int outputSize)
{
int StringCount = 0;
int index = 0;
while (input.length() > 0 && StringCount < outputSize)
{
index = input.indexOf(delimiter);
if (index == -1)
{
output[StringCount++] = input;
break;
}
else
{
output[StringCount++] = input.substring(0, index);
input = input.substring(index + 1);
}
}
for (int i=StringCount;i<outputSize;i++){
output[i]="";
}
}
void loop () {
delay(1000);
}