I want to make copies of the exe file itself multiple times.
I tried the following code:
#include <fstream>
#include <string>
int main() {
std::ifstream from("main.exe", std::ios::binary);
auto buf { from.rdbuf() };
for(int x { 0 }; x <= 10; ++x) {
std::string name { "main" + std::to_string(x) + ".exe" };
std::ofstream out(name, std::ios::binary);
out << buf;
out.close();
}
from.close();
return 0;
}
But it doesn't work as I expected (It does not copy the executable repeatedly. See the size column in the following screenshot):
Please help me to solve this problem.
Thanks.

