by cldr · 13y ago · 0 comments
Plus, he could have reduced lines even further to get down to about 6, like
vector<string> data;
string line;
for (ifstream ifile(argv[1]); getline(ifile, line);)
data.push_back(line);
sort(begin(data), end(data));
copy(begin(data), end(data), ostream_iterator<string>(ofstream(argv[2]), "\n"));
And his `return 0` was superfluous so I removed it.Unfortunately we work with iterator pairs in C++; if we had ranges like D does, we could turn those last two into
copy(sort(data), ...)
but alas we cannot.