c++ - How do I parse a txt file which erases all the lines except what I need? -
i want parse text file want , create txt file in c++. have text file looks this.
user : group : comment1 : comment2 : *** label *** id : nick pass : sky123 number id : 9402 *** end of label *** ######################################
and goes on. want create new txt file leaves lines contains colon(:) , erase rest such "* label *", , save result in new txt file. answer txt file be
user : group : comment1 : comment2 : id : nick pass : sky123 number id : 9402
how do in simple way? thank much.
i have not tested this, idea.
void foo(ifstream& ifs, ofstream& ofs) { while ( !ifs.eof() ) { string line; getline(ifs, line); if (line.find(":") != string::npos) ofs << line; } }
Comments
Post a Comment