milan.rajik
Banned
Why this code is not working as expected ?
I need to extract date and time from AT+CMGR header. The function has these arguments.
*s1 = in buffer
*s2 = out buffer
It works like this. It loops unsti it finds the 7th double quotes and then after coming out of loop it increments once. Then it loops again until '+' is encountered which is 1st '+' after 7th '"'. so, p = 7 and q = 1. Also if *s1 and *s2 is loaded into watch window it doesn't show the whole array.
I need to extract date and time from AT+CMGR header. The function has these arguments.
*s1 = in buffer
*s2 = out buffer
It works like this. It loops unsti it finds the 7th double quotes and then after coming out of loop it increments once. Then it loops again until '+' is encountered which is 1st '+' after 7th '"'. so, p = 7 and q = 1. Also if *s1 and *s2 is loaded into watch window it doesn't show the whole array.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 char buffer1[] = "+CMGR: \"REC UNREAD\",\"+919900516837\",\"\",\"14/12/17,23:44:27+22\"\r\n20!4#gt\r\n\r\n"; char buffer2[20]; void GSM_Split(char *s1, char *s2, char p, unsigned int startIndexP, char q, unsigned startIndexQ) { unsigned int a = 0, b = 0; while(a != startIndexP) { if(*s1 == p)a++; *s1++; } *s1++; while(b != startIndexQ) { if(*s1 == q)b++; *s2++ = *s1++; } *s2 = '\0'; } GSM_Split(buffer1, buffer2, '"', 7, '+', 1);