i have created a header that allows me to spawn copies of a file a given number of times with a random new name. however, the name it gives the files is not really controlled by anything i do and i don't understand where it comes from. here is the code for spawn.h:
Code:
#include <fstream>
using namespace std;
bool copy_paste(const char SRC[], const char DEST[])
{
ifstream src;
ofstream dest;
src.open(SRC, ios::binary);
dest.open(DEST, ios::binary);
dest << src.rdbuf();
dest.close();
src.close();
}
void spawn(const char SRC[], int copies)
{
for(int i = 0; i != copies + 1; i++)
{
const char newName[] = {i};
copy_paste(SRC, newName);
}
}
so i would use it in something like
Code:
#include "spawn.h"
int main()
{
spawn("somefile.extension", 5);
}
this is a very basic version of what i want the end to be so i know there are some redundant pieces. would someone please tell me how to control the name of the output file... i want it to increment (for example: a, b, c, ...) and have the same potential extension.
thanks in advance