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;

你可能感兴趣的:(c++编程)