Mysterious Issue in Replicating Binary files in C : <p>Hey community i'm having trouble in replicating binary files from the command line have a look at my try. The code under copies the first character on the srcFile and stops somehow, can you guys help me figure the way i can fix this and the reason it happens?</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#define BUFSIZE 8500
int main(int argc, char** argv)
{
char buffer[BUFSIZE];
size_t currBit;


FILE *srcFile = fopen(argv[1], "r+b");

if (!srcFile)
{
    printf("source file doesnt exist or problem with allocating the memory");
    return 1;
}
FILE *dstFile = fopen(argv[2], "r+b");
if (dstFile)
{
    printf("Destination file already exists\nfor overwriting enter 1 \nfor exit enter 2\n");
    _flushall();
    switch (getchar())
    {
    case '1':
        fclose(dstFile);
        dstFile = fopen(argv[2], "w+b");
        if (!dstFile)
        {
            printf("Problem with allocating the memory");
        }
        while ((currBit = fread(buffer, sizeof(char),BUFSIZE, srcFile) &gt; 0))
        {
            fwrite(buffer, sizeof(char), currBit, dstFile);
        }

        break;
    case '2':
        system("pause");
        return 0;
        break;
    default:
        printf("next time you should enter numbers as following");
    }
}
else
{
    dstFile = fopen(argv[2], "w+b");
    while ((currBit = fread(buffer, sizeof(char), BUFSIZE, srcFile) &gt; 0))
    {
        fwrite(buffer, sizeof(char), currBit, dstFile);
    }
    if (!dstFile)
    {
        printf("Problem with allocating the memory");
    }
}


fclose(srcFile);
fclose(dstFile);

getchar();
return 0;
}
</code></pre>

<p>Input Source file:
10100101</p>

<p>Expected Output From Destination File:
10100101</p>

<p>Destination File Output:
1</p>
