hello guys i made a program which copying binary files, but i have a problem: when im trying to copy the field of the source file to the target file its removing all the field of the target file. how can i solve this problem?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv)
{
FILE *source, *target;
const size_t buffer_size = 8192;
char buffer[100];
int strint[100];
int a;
source = fopen(argv[1], "rb");
if (source != NULL)
{
return -1;
}
target = fopen(argv[2], "w+b");
while (1)
{
a = fread(buffer, sizeof(char), buffer_size, source);
if (!feof(source))
{
fwrite(buffer, sizeof(char), buffer_size, target);
}
else
{
break;
}
}
fclose(target);
fclose(source);
system("pause");
return 0;
}