在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
#include<iostream> #include<string> using namespace std; int main() { //string filePath = "D:\\statistics_chengqichao\\qcc\\biaoxiandianyun.xyz"; //int nPos = filePath.rfind('\\'); //string prefixPath = filePath.substr(0, filePath.length() - nPos-1); //cout << prefixPath << endl; string filename = "C:\\MyDirectory\\MyFile.txt"; string directory; const size_t last_slash_idx = filename.rfind('\\'); if (std::string::npos != last_slash_idx) { directory = filename.substr(0, last_slash_idx); } cout << directory << endl; system("pause"); return 0; }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论