Это MWE того, как скопировать из файла в другой файл
#include <algorithm>
#include <fstream>
#include <iterator>
int main() {
std::ifstream ifs("input");
std::ofstream ofs("output");
std::copy(std::istream_iterator<int>(ifs),
std::istream_iterator<int>(),
std::ostream_iterator<int>(ofs, ", "));
}
Учитывая файл input
с содержанием 1 2 3 4 5
, файл output
будет заполнен 1, 2, 3, 4, 5,
.