How to make n copies of a binary c ++ program?

Closed due to the fact that the issue is too general for the user194374, cheops , Kromster , Streletz , aleksandr barakin Jun 20 '16 at 7:22 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • five
    Make one copy, repeat n - 1 times. - VladD 4:42 pm
  • @VladD is logical, but how to make 1? - true
  • copy and paste apparently - pavel
  • @pavel independently to be copied - true
  • 2
    @true: Code of what? std::system((std::string("copy \"") + srcpath + "\" \"" + dstpath + "\"").c_str()) ? - VladD

1 answer 1

In C++17 you can do this:

 #include <filesystem> int main() { const int copies = 42; for (int i = 0; i < copies; ++i) std::filesystem::copy("binary", "binary." + std::to_string(i)); } 

In VS2015 will look like this:

 #include <filesystem> int main() { const int copies = 42; for (int i = 0; i < copies; ++i) std::tr2::sys::copy("binary", "binary." + std::to_string(i)); } 

And in GCC6.1 like this:

 #include <experimental/filesystem> int main() { const int copies = 42; for (int i = 0; i < copies; ++i) std::experimental::filesystem::copy("binary", "binary." + std::to_string(i)); }