The Database Managers, Inc.

Contact The Database Managers, Inc.


Use an RSS enabled news reader to read these articles.Use an RSS enabled news reader to read these articles.

How can I append a file to another file using STL algorithms and iterators?

A:  Try this:

#include <algorithm>
#include <fstream>

int main()
{
    std::ifstream in("fileforread.tmp");
    std::ofstream out("fileforappend.tmp",std::ios_base::app);

    std::istreambuf_iterator<char> src(in.rdbuf());
    std::istreambuf_iterator<char> end;
    std::ostream_iterator<char> dest(out);

    std::copy(src,end,dest);
}


Other Popular C++ topics:

C++ FAQ Services | Programming | Contact Us | Recent Updates
Send feedback to: