int main() { std::ifstream fListIn("D:\AgeClassification\asian\valData\0.txt"); string readLineName; ofstream fout("D:\AgeClassification\asian\valData\valData.txt"); //创建一个data.txt的文件 while (getline(fListIn, readLineName)) { //string labelName = readLineName.substr(readLineName.f ); int begin = readLineName.find_first_of("\"); int end = readLineName.find_last_of("\"); //cout << "begin=" << begin << "," << end << endl; string labelName(readLineName.substr(begin+1, end-begin-1));//截取两个反斜杠之间的字符标签 //cout << "labelName=" << labelName << endl; fout << readLineName << " " << labelName << endl; } fout.close(); return 0; }
bat文件
dir/s/on/b >0.txt