函数:
void SuperCString::Split(CString rawString,char sp,CString* sp_arr[],int* length)
{
CString* arr = new CString[*length];
int pos = 1;
int repeatcount = 0;
while(pos > 0){
if(repeatcount >= *length){
break;
}
pos = rawString.Find(sp,0);
if(pos > -1)
arr[repeatcount] = rawString.Mid(0,pos + 1);
else
arr[repeatcount] = rawString;
rawString = rawString.Mid(pos + 1);
repeatcount++;
}
*length = repeatcount;
*sp_arr = arr;
}
调用方式:
SuperCString scs;
CString* arr = new CString[5];
int len = 5;
scs.Split(header,'\n',&arr,&len);
CString outaa;
outaa.Format(L"%d",len);
for(int i = 0;i<len;i++){
outaa += L"\r\n" + arr[i];
}
AfxMessageBox(outaa);
return;
posted on 2009-01-05 12:04
BirdsHover 阅读(1514)
评论(0) 编辑 收藏 引用