Like under:
CString strOrg;
strOrg="1/2/33/4/5/6";
I wanna output:
1
2
33
4
5
6
and it's better to split the string into a string array
for your help,there are a "thanks" only

解决方案 »

  1.   

    I think you can do it,like:
    CString a[MaxNum];
    CString strOrg,strTemp,str;
    strOrg="1/2/33/4/5/6";
    int n=strTemp.Find(_T('//'));
    int i=0;
    while(n!=-1)
    {
        a[i++]=strTemp.Left(n);
        str=strTemp.Right(strTemp.GetLength()-n-1);
        strTemp=str;
        n=strTemp.Find(_T('//'));
    }
      

  2.   

    use Tokenize, CString::Tokenize
      

  3.   

    I find a c-runtime function 
    strtok
    that's good
      

  4.   

    #include <TCHAR.H>
    #include <iostream.h> int nBegin=0, nEnd;
    CStringArray strAry;
    char subStr[20];
    char org[100] = ("1/2/33/4/5/6");
    CString strOrg(org);
    do 
    {
    nEnd = strOrg.Find('/', nBegin);
    if ( -1 != nEnd )
    {
    memcpy(subStr, org+nBegin, nEnd);
    subStr[nEnd-nBegin] = '\0';
    CString temp(subStr);
    strAry.Add(temp);
    nBegin = nEnd+1;
    }
    }while (-1 != nEnd ); int nCount = strAry.GetSize();
    for (int i=0; i<nCount; ++i)
    {
    cout << (LPCTSTR)strAry.GetAt(i) << endl;
    }
      

  5.   

    strtok, wcstok, _mbstok
    Find the next token in a string.char *strtok( char *strToken, const char *strDelimit );wchar_t *wcstok( wchar_t *strToken, const wchar_t *strDelimit );unsigned char *_mbstok( unsigned char*strToken, const unsigned char *strDelimit );
      

  6.   

    #include <string.h>
    #include <stdio.h>
    #include <windows.h>
    #include <iostream.h>
    char seps[]="/";
    char *token;void main( void )
    {
        char string1[]="1/2/33/4/5/6";    printf( "%s\n\nTokens:\n", string );
        token = strtok( string, seps );
        while( token != NULL )
    {
            cout<<token; 
            token = strtok( NULL, seps );
    }
    cout<<buff;
    }你只要先把你的CString转换成char*类型就OK了