1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| char teststr[] = "AF/CCT1456 12;22pp XX.XXM YY.YYG"
char tempBuff[20], temp[20];
void SplitBuffer(char *to, char *from, char delimit1, unsigned char delimit1Count, char delimit2, unsigned char delimit2Count, char *(*mystrcat)(char *, char *), char *(*mystrcpy)(char *, char *), char *(*strtokn)(char *, char *), void *(*mymemset)(void *, char, int), int lenBuff, char *tmpBuff) {
unsigned delimit1Cnt = 0, delimit2Cnt = 0;
unsigned char tmp[2];
tmp[0] = delimit1;
tmp[1] = '\0';
(*mystrcpy)(to, (*strtokn)(from, tmp));
while(++delimit1Cnt != delimit1Count){
(*mystrcpy)(to, (*strtokn)(0, tmp));
}
(*mymemset)(to, '\0', lenBuff);
tmp[0] = delimit2;
(*mystrcpy)(to, (*strtokn)(0, tmp));
while(++delimit2Cnt != delimit2Count){
(*mystrcat)(to, (*strtokn)(0, tmp));
}
(*mystrcpy)(tmpBuff, to);
}
void main() {
while(1){
SplitBuffer(&tempBuff, &teststr, ' ', 2, 'M', 1, &strcat, &strcpy, &strtok, &memset, 20, &temp);
SplitBuffer(&tempBuff, &teststr, ' ', 3, 'G', 1, &strcat, &strcpy, &strtok, &memset, 20, &temp);
}
} |