🔷 C++
From File To File

Updated at 2013-11-13 12:07

Read from a file, sort lines, write to another file in C++11.


using namespace std;

int main(int argc, char **argv) {
    ifstream ifile(argv[1]);
    ofstream ofile(argv[2]);
    string line;
    vector<string> data;
    while (getline(ifile, line)) {
    sort(data.begin(), data.end());
    for (const auto &i : data) {
        ofile << i << std::endl;
    return 0;