标签:length ash turn end 文件 str pac direct 路径
#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; }
标签:length ash turn end 文件 str pac direct 路径
原文地址:https://www.cnblogs.com/yibeimingyue/p/11942963.html