Split string into equal slices chunks 10:5=2

Dears, I want ask you for help.
I need divide one string of 10 numbers, to five strings with 2 numbers. Can you help me how? Thanx


String recivedMessage = "1946400156";

char first  = recivedMessage.substring(0, 1)[0];
char second = recivedMessage.substring(1, 2)[0];
char third  = recivedMessage.substring(2, 3)[0];
char forth  = recivedMessage.substring(3, 4)[0];
char fifth  = recivedMessage.substring(4)[0];

Serial.println("message: ");
Serial.println(first);
Serial.println(second);
Serial.println(third);
Serial.println(forth);
Serial.println(fifth);

/* I got next:

1
9
4
6
4

But I need next:
19
46
40
01
56

*/

A single char cannot contain '19'

OK, sorry, I have it.

String first  = newStr1.substring(0, 2);
String two = newStr1.substring(2, 4);
String third  = newStr1.substring(4, 6);
String forth  = newStr1.substring(6, 8);
String fifth  = newStr1.substring(8);

Thanx, SOLVED

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.