Universal File Duplicator I made a simple Universal-File-Duplicator (Example: make 125 duplicates of one file).
Very useful if you want to fill a whole USB flash drive or an old harddisk with an important file (Example: Bitcoin wallet.dat or privatekey) and you don't want to hit Ctrl+V all the time...

Suggestions? Improvements?

#include "stdafx.h"
#include "stdio.h"
#include &lt;stdlib.h&gt;
#include &lt;strstream&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;conio.h&gt;
using namespace std;

int main(int argc, char* argv[])
{

    char nummer[1000000], sourcefile[255], targetfile[255], targetfileneu[255], endung[255];
    int i = 0;
    int anzahl = 0;
    ifstream Quelldatei;

    printf("Welcome! You are using UNIVERSAL-DATEI-DUPLIKATOR v1.0\n");
    printf("Filename? (Example: test.txt)\n");
    gets(sourcefile);
    printf("New Filename without ending? (Example: filename)\n");
    gets(targetfile);
    printf("Ending? (Example: .txt)\n");
    gets(endung);

    printf("How many times do you want to create the file?\n"); 
    scanf("%d", &amp;anzahl);

    for (i = 0; i &lt; anzahl; i++)
    {
        sprintf(nummer, "%ld", i);
        strcpy(targetfileneu, targetfile);
        strcat(targetfileneu, nummer);
        strcat(targetfileneu, endung);
        printf("Targetfilename: %s\n", targetfileneu);

        Quelldatei.open(sourcefile, ios::binary);
        if (!Quelldatei)
        {
            cerr &lt;&lt; "ERROR!\n";
            return 0;
        }                                    
        ofstream Zieldatei(targetfileneu, ios::binary);
        if (!Zieldatei)
        {
            cerr &lt;&lt; "ERROR!\n";
                    return 0;
        }
        else
        {
            int c; 
        while ((c = Quelldatei.get()) &gt;= 0) { Zieldatei.put(c); }
        }
        memset(&amp;targetfileneu[0], 0, sizeof(targetfileneu));
        Quelldatei.close();
        Zieldatei.close();
    }
    printf("SUCCESS!\n");
    system("pause");
    return 0;
}
You've got a using namespace std; in your code. Don't do that. (No, really).



gets is dangerous; don't use it. Streams are so much more convenient anyway! For instance, you could write:

std::string sourcefile, targetfile, endung;
std::cout &lt;&lt; "Welcome! You are using UNIVERSAL-DATEI-DUPLIKATOR v1.0\n"
          &lt;&lt; "Filename? (Example: test.txt)\n";
std::cin &gt;&gt; sourcefile;
std::cout &lt;&lt; "New Filename without ending? (Example: filename)\n";
std::cin &gt;&gt; targetfile;
std::cout &lt;&lt; "Ending? (Example: .txt)\n";
std::cin &gt;&gt; endung;

int anzahl;
std::cout &lt;&lt; "How many times do you want to create the file?\n";
std::cin &gt;&gt; anzahl;




Opening the input file only once and resetting the stream to the beginning for each copy may allow the stream to make better use of buffering, reducing the number of seeks required.

Also, streams can be copied directly to streambufs using operator&gt;&gt;.

std::ifstream Quelldatei(sourcefile, std::ios::binary);
for (int i = 0; i &lt; anzahl; ++i) {
    Quelldatei.seekg(0);
    std::ostringstream output_filename(targetfile);
    output_filename &lt;&lt; i &lt;&lt; endung;
    std::ofstream Zieldatei(output_filename, std::ios::binary);
    Quelldatei &gt;&gt; Zieldatei.rdbuf();
    Zieldatei.close();
}
std::cout &lt;&lt; "SUCCESS!" &lt;&lt; std::endl;
system("pause");