随笔-9  评论-6  文章-5  trackbacks-0
函数:

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 阅读(1452) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理