pos = dlg.GetStartPosition();
CString *pFiles = new CString[iFileCount];
iFileCount = 0;
  while (pos)
 {
     CString sFile = dlg.GetNextPathName(pos);
     pFiles[iFileCount++] = sFile;
}

解决方案 »

  1.   

    **pFiles 好像是指向指针的指针
      

  2.   

    这就是指向指针的指针!
    thank in c++
      里有自己好好看看吧
      

  3.   

    while (pos)
     {
         CString sFile = dlg.GetNextPathName(pos);
         *pFiles[iFileCount++] = new char[MAX_PATH+1];//改写
      

  4.   

    这有什么值得不明白的,二级指针呀。
    你怎么可以直接用CString给数组赋值呢?
    这样吧:
    strcpy(pFiles[iFileCount] , sFile);
    另外,你的iFileCount已经加加了,而后面一个还没分配呢,改为:
    CString sFile = dlg.GetNextPathName(pos);
         pFiles[iFileCount] = new char[MAX_PATH+1];
         strcpy(pFiles[iFileCount++] , sFile);
      

  5.   

    你这里的char **pFiles实际是一个字符串数组。
    pFiles[i]相当于一个字符串。
    可以通过lstrcpy(pFiles[i],(LPCTSTR)sFile)将sFile的内容复制到pFiles[i]。
      

  6.   

    你的疑惑大概是这两处吧,
    1)为什么要char **pFiles = (char **) new int [iFileCount];
      这里pFiles是一个文件串指针数组,其每个元素指向一个字符串
      不过,我觉得完全可以写成char **pFiles=new char *[iFileCount];
      读起来不至于这么晦涩
    2)编译出错处(pFiles[iFileCount] = sFile; )
      我个人认为是CString处于安全考虑,它没有重载 operator char *(),
      它只重载了operator const char *(),但无论如何这里你也不应该这样作,
      幸好这里编译没通过,否则这就造成你程序中一个不小的bug了.正确做法应该像
      我楼上那位这样.
    补充一句,你的iFileCount的自增的位置确实不对