c++截取指定兩個字符之間的字符串

string picture_name = “edj_sdjj.bmp”;//this is picture number
            std::cout << "圖片名:" << picture_name << endl;
            int nPos_1 = picture_name.find("_");
            int nPos_2 = picture_name.find_last_of(".");
            string name_name="";
            name_name = picture_name.substr(nPos_1+1,nPos_2-nPos_1-1);
           // name_name = picture_name.substr(t1,t2);//是指從t1位置開始,長度爲t2的字符串
            cout <<"截取的文件名:"<< name_name << endl;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章