anerDev:
I have a char in this format:
Is a date + time: date 2015 02 24 time 17 27 17
I need to split this char and convert it into a multiple int.
Int like: year, month, day, hour, minute, second.
I don't need the part ".000".
But I don't know exactly how proceed.
Because there aren't a delimiter in the string.
I think that I need a for cycle, but I don't know exactly how do.
Here is a demo that uses "sscanf" to cut the string into integers and reformats using "snprintf":
void setup()
{
Serial.begin(9600);
char tmp[]="20150224172717.000"; // original string
Serial.print("Original: ");Serial.println(tmp);
int year, month, day, hour, minute, second; // some int variables
// cut original string into pieces
sscanf(tmp,"%04d%02d%02d%02d%02d%02d",&year,&month,&day,&hour,&minute,&second);
char strbuf[51]; // new string buffer
// new formatting
snprintf(strbuf,sizeof(strbuf),"German date: %02d.%02d.%04d Time ==> %02d:%02d:%02d",day,month,year,hour,minute,second);
Serial.println(strbuf);
}
void loop(){}
Using 'sscanf' the cutting into integers is a one-liner.