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":
char tmp="20150224172717.000"; // original string
int year, month, day, hour, minute, second; // some int variables
// cut original string into pieces
char strbuf; // new string buffer
// new formatting
snprintf(strbuf,sizeof(strbuf),"German date: %02d.%02d.%04d Time ==> %02d:%02d:%02d",day,month,year,hour,minute,second);
Using 'sscanf' the cutting into integers is a one-liner.