There are two files a and B. I want a file C, which contains B files to remove data that is in the same way as.
Written in C ++, fstream, ifstream, set, and vector are used.
#include <fstream>#include <iostream>#include <vector>#include <set>using namespace std;struct strless : public std::binary_function<const char*, const char*, bool>{ bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }};int _tmain(int argc, _TCHAR* argv[]){ ifstream comparefile; comparefile.open("E:\\a\\tasks.txt",ios::in); set<char*,strless> sline; char (*lines)[100] = new char[200][100]; int count = 0; while(!comparefile.eof()) { comparefile.getline(lines[count],100); sline.insert(lines[count]); ++count; } comparefile.close(); ifstream sourcefile; sourcefile.open("E:\\a\\ttt.txt",ios::in); char (*lines1)[100] = new char[1000][100]; count = 0; vector<char*> vline; while(!sourcefile.eof()) { sourcefile.getline(lines1[count],100); if(!sline.count(lines1[count])) vline.push_back(lines1[count]); ++count; } sourcefile.close(); fstream targetfile; targetfile.open("E:\\a\\list.txt",ios::app); vector<char*>::iterator vitr = vline.begin(); while(vitr!= vline.end()) { targetfile<<*vitr<<endl; ++vitr; } targetfile.close(); return 0;}