[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;
}

猜你喜欢

转载自www.cnblogs.com/lightmonster/p/11505787.html
今日推荐