如果我把“TV_WDMext.AddReg, Cap713x.AddRegProteus, Cap713.AddReg, Cap7130.AddReg, Prop7134.AddReg, 34COM.AddReg”
放到一个CString 类型里
怎么一个一个得到段名如Cap713x.AddRegProteus、 34COM.AddReg呢?

解决方案 »

  1.   

    _CRTIMP char *  __cdecl strtok(char *, const char *);
    #include <string.h>
    #include <stdio.h>char string[] = "A string\tof ,,tokens\nand some  more tokens";
    char seps[]   = " ,\t\n";
    char *token;void main( void )
    {
       printf( "%s\n\nTokens:\n", string );
       /* Establish string and get the first token: */
       token = strtok( string, seps );
       while( token != NULL )
       {
          /* While there are tokens in "string" */
          printf( " %s\n", token );
          /* Get next token: */
          token = strtok( NULL, seps );
       }
    }
    OutputA string   of ,,tokens
    and some  more tokensTokens:
     A
     string
     of
     tokens
     and
     some
     more
     tokens
      

  2.   

    小鸟,人家是CString类型了~int nLast = 0, nFound = 0;
    CString cString = "TV_WDMext.AddReg, Cap713x.AddRegProteus, Cap713.AddReg, Cap7130.AddReg, Prop7134.AddReg, 34COM.AddReg";
    while( (nFound = cString.Find( ",", nLast ))!=-1 )
    {
        printf( "%s", cString.Mid( nLast, nFound - nLast - 1 ) );
        nLast = nFound + 2; //跳过空格
    }
      

  3.   

    有函数可用吗?
    我说的是把那一串存入一个CString 类型里