c:\xxxxx\xxx\123355235553322.txt
c:\xxxxx\xxx\长度不定, 怎样取得.txt前面六位,并转为int型?

解决方案 »

  1.   

    strrchr 查找.的位置,然后再获得他前面的字符,转换用atoi
      

  2.   

    CString str = _T("c:\\xxxxx\\xxx\\123355235553322.txt");
    int nPos = str.Find(_T(".txt"));
    CString str1 = str.Mid(nPos-6, 6);
    int n = atoi(str1);
      

  3.   

    CString str = "c:\xxxxx\xxx\123355235553322.txt";
    int i = str.ReverseFind('.');
    int j = str.ReverseFind('//');
    CString strTmp = str.Mid(j + 1,i - j - 1);
    int iValue = atoi(strTmp);