int strInfoDecodeToIntList(char *buf, char compartChr, CString *list, int listCnt, int *cnt)
{
char *p1 = NULL, *p2 = NULL, numInfoStr[128] = { 0 };
int i = 0;
unsigned int len = 0, srtSize = sizeof(numInfoStr);
if (!buf || !list || listCnt <= 0 || !cnt) return -1;
*cnt = 0;
p1 = buf;
p2 = p1;
while (p2 && i < listCnt)
{
p2 = strchr(p2, compartChr);
if (p2)
{
if ((len = p2 - p1)<srtSize)
{
strncpy(numInfoStr, p1, len);
list[i] = numInfoStr;
}
p2++;
p1 = p2;
}
else
{
if (strlen(p1)<srtSize)
{
strcpy(numInfoStr, p1);
list[i] = numInfoStr;
}
}
i++;
}
*cnt = i;
return 0;
}
char* buf: 你要进行拆分的字符串
char compartChr: 某一进行比较的字符
CString* list: 拆分后形成的数组
int listCnt: 你预估拆分后数组的大小
int* cnt: 实际上拆分后数组的大小