//待分隔的字符串
TCHAR string1[] = _T("A,,B,c,D");
//分隔符
TCHAR seps[] = _T(",");
//每次处理结果
TCHAR *token1 = NULL;
//中间指针
TCHAR *next_token1 = NULL;
token1 = wcstok_s(string1, seps, &next_token1);
CString strTemp[10];
INT i = 0;
while (token1 != NULL)
{
TRACE(_T(" %s\n"), token1);
strTemp[i++] = token1;
token1 = wcstok_s(NULL, seps, &next_token1);
}
TCHAR string2[] = _T("1,,2,3,4");
//用数组存所有结果
CString strResult[10];
//中间结果
CString strTempResult;
INT j = 0;
while (AfxExtractSubString(strTempResult, string2, j, ','))
{
strResult[j] = strTempResult;
j++;
}
TRACE(_T("%d\n"), j);