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 .
|
1 answer
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)); } |
n - 1times. - VladD 4:42 pmstd::system((std::string("copy \"") + srcpath + "\" \"" + dstpath + "\"").c_str())? - VladD