include
include
include
include
include
using namespace std;
ifstream & open_file(ifstream &in, const string & file)
{in.close();
in.clear();
in.open(file.c_str());
return in;
}
int main(int argc,char *argv[])
{
string filename;
filename = argv[1];cout << "正在文本去重:" << filename << endl;
cout << "请稍后...";
set ss;
set ::iterator iter;
ifstream infile;
ofstream ofile;
if (!open_file(infile,filename ))
{
cerr << "没有加载文件!" << endl;
return 0;
}
string textline;
while (getline(infile, textline))
if(strstr(textline.c_str()," "))
{
ss.insert(textline);
}
ofile.open(argv[2]);
for (iter = ss.begin();iter != ss.end();iter++)
ofile << *iter << endl;
return 0;
}
赏
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!