CString find the last entry

后端 未结 5 1800
无人共我
无人共我 2021-01-23 08:18

I have two CString s1 and CString s2. I need find the last entry s2 in s1. I can find any metod in CString like in C# LastIndexOf. I am nooby in c++.

5条回答
  •  北海茫月
    2021-01-23 09:02

    you don't need implement a self function. std has provide a function: std::string::find_last_of. for example:

    std::string str("c:\windows\winhelp.exe");
    unsigned found = str.find_last_of("/\\");
    std::cout << " path: " << str.substr(0,found) << '\n';
    std::cout << " file: " << str.substr(found+1) << '\n';
    
    
    path: c:\windows
    file: winhelp.exe
    

提交回复
热议问题