在一段字符串中删除固定的一段,得出结果"? VC
C:\\windows\\system32\\ctfmon.exe 这是一段字符串。我想删去\\system32\\ctfmon.exe ,急求代码??

解决方案 »

  1.   

    CString strFilepath = "C:\\windows\\system32\\ctfmon.exe";
    CString str = strFilepath.Left(strFilepath.Find("\\system32\\ctfmon.exe"));
    str就是你需要的
      

  2.   

    C:\dosh\ghos\Ghostexp.exe "%1"这是一段,我想去除\ghos\Ghostexp.exe "%1" 怎么写代码啊?
      

  3.   

    CString strFilepath = "C:\\dosh\\ghos\\Ghostexp.exe \"%1\"";
    CString str = strFilepath.Left(strFilepath.Find("\\\ghos\\Ghostexp.exe \"%1\""));
      

  4.   

    或者直接找第二个\:CString strFilepath = "C:\\dosh\\ghos\\Ghostexp.exe \"%1\"";
    int Index = 0;
    for(int i=0; i<2; i++)
    Index=strFilepath.Find(Index,'\\');
    CString str = strFilepath.Left(Index);