[C++]头文件排序

using namespace std;
using namespace std::placeholders;
bool comP(string &a, string& b) {
    return a < b;
}
int main()
{
    ofstream of;
    of.open("headfile.h");
    ifstream ifile("head_file.h");
    vector<string> head;
    string v;
    while (getline(ifile, v))
    {
        head.push_back(v);
    }
    sort(head.begin(), head.end(), comP);
    for (auto & h : head)
        of << h << endl;
    return 0;
}

 

posted @ 2019-09-11 13:39  Lightmonster  阅读(322)  评论(0编辑  收藏  举报