看:
bool  Initstr(char *Dest[],char *Sour)
{
    char *temp=Sour;
    for(int i=0;i<MAX_VALUE;i++)\\MAX_VALUE为文件名数
    {
        while((*Dest[i]++ = *temp++) != ','
  && *temp != '\0')
        {
if(*temp == '\\')
                *Dest[i]++ = '\\';
        } 
if(*temp == '\0')break;
    }
    return TRUE;
}
函数判断了字符串最后一个字符不为“,”的情况,假如那位高手有更有水平的代码,可以互相讨论

解决方案 »

  1.   

    看:
    bool  Initstr(char *Dest[],char *Sour)
    {
        char *temp=Sour;
        for(int i=0;i<MAX_VALUE;i++)\\MAX_VALUE为文件名数
        {
            while((*Dest[i]++ = *temp++) != ','
      && *temp != '\0')
            {
    if(*temp == '\\')
                    *Dest[i]++ = '\\';
            } 
    if(*temp == '\0')break;
        }
        return TRUE;
    }
    函数判断了字符串最后一个字符不为“,”的情况,假如那位高手有更有水平的代码,可以互相讨论
      

  2.   

    不必给100了,C下有个函数完全胜任:strtok()#include <string.h>
    #include <stdio.h>char string[]= "c:\mydir\file1.txt,d:\mydir\fi.txt,d:\dkg\ffff.exe,c:\dhgk\sdjgi.dll,";
    char seps[]   = ",";
    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 );
       }
    }
    测试上面已通过注意到了,打印出来的没了'\',好办。再用CString::Repleace()把每个子串中的'\\'替换为'\\\'自己试吧,已经很简单了。
      

  3.   

    CString CDialogImport::ChangeType(CString tt)
    {
    //AfxMessageBox("good");
    TCHAR a;
    TCHAR b;
     for (int j=0;j<tt.GetLength();j++)
     {
    a=tt.GetAt(j);
    if (a<(0x00))
    {
    j=j+1;
    b=tt.GetAt(j);
    if(b>0x00)
    {
    if(b=0x27)
    { // '=0x2
    tt.SetAt(j-1,0x20) ;
    }
    }

    }
     }
    //  AfxMessageBox(tt);
     return tt;
    }
    这个是我以前对数据导入时半个中文字符的处理函数,应该对你有帮助
      

  4.   

    CStringArray *Convert(CString mystring)
    {
    CString temp = mystring;
    cstring temp1;
    cstringarray arraystring;
      unsigned int t = temp.GetLength();
      for ( unsigned int i = 0 ; i< t ;i++ )
    {  if(temp[i] != '\')
    temp1 +=temp[i];
    else
    {
    temp1+='\';
    temp1+='\';
    arraystring.add(temp1);
    }}
    return arraystring;
    }思路就这样了,你自己改吧。
      

  5.   

    strtok 函数可以做到InitStr(char* src, char* dest[])
    {
      int i = 0
      char *sep = ",";
      char *p = strtok(src, sep);
      while( p!= NULL ) {
        MyStrCpy(dest[i], p);
        p = strtok( NULL, sep);
        ++ i;
      }
    }
    void MyStrCpy(char *dest, char *src)
    {
       int i = 0;
       char p[100];
       char* s = src;
       while(*s) {
          if (*s  != '\\')
              p[i] = *s;
          else
              p[i] = *s; ++ i; p[i] = *s;
          ++ i;
       }
       p[i] = '\0';
       dest = strdup(p);
    }
      

  6.   

    同意 zhang_wei_question(张炜) !!使用strtok()。
      

  7.   

    我采用了absolute_good((NO.1)狗狗)的方法。
    谢谢大家,给分!!