首先,分离出一个一个字符串
CString cstrTemp = "12,-12,13";
CString cstrSplit = ",";
CString cstrData("");
int nIndex=0, nCnt=0;
while (TRUE)
{
nIndex = cstrTemp.Find(cstrSplit);
if(nIndex == -1)
{
acstrRet.Add(cstrTemp);
nCnt++;
return nCnt;
}
else
{
cstrData = cstrTemp.Left(nIndex);
cstrTemp = cstrTemp.Right(cstrTemp.GetLength() - (nIndex + cstrSplit.GetLength()));
acstrRet.Add(cstrData);
nCnt++;
}
}然后,将每个字符串转换为数值,也就是逐个将'0'...'9'转换为0...9

解决方案 »

  1.   

    sscanf

    strTok atol;
       token = strtok( string, ",");
       while( token != NULL )
       {
          /* While there are tokens in "string" */
          atol(token );
          /* Get next token: */
          token = strtok( NULL, "," );
       }
      

  2.   

    请问 你的那个Add 是不是 CString 的 成员函数啊
      

  3.   

    是动态数组的example: CObArray  ----上面 2 位提供了 MFC 和 C的方法都可以