void Split(CString content, CString pattern, CAtlArray<CString>& strlist)
{
int iPos = content.Find(pattern), iStart = 0;
while (iPos != -1)
{
strlist.Add(content.Mid(iStart, iPos - iStart));
iStart = iPos + pattern.GetLength();
iPos = content.Find(pattern, iStart);
}
if (iStart <= content.GetLength())
strlist.Add(content.Mid(iStart));
}
下面是我写的一个分割IP地址的函数
void SplitIp(CString strIp, BYTE &b1,BYTE &b2,BYTE &b3,BYTE &b4)
{
CString strTemp;
int nCount=0;
BYTE BIp[4];
char *ss=strIp.GetBufferSetLength(strIp.GetLength());
char *p;
for (p=strtok(ss, "."); p!=NULL; p=strtok(NULL, "."))
{
BIp[nCount++]=atoi(p);
}
b1 = BIp[0];
b2 = BIp[1];
b3 = BIp[2];
b4 = BIp[3];
}