hello guys i am trying to make a program which which copying binary files (the values) from the source to the target. but i has a mistake and i don't know how to solve that, how can i complete the code?
int main(int argc, char ** argv)
{
FILE * source, *target;
int numr, numw;
char buffer[100];
source = fopen(argv[1], "rb");
target = fopen(argv[2], "rb");
if ((source = fopen(argv[1], "rb")) == NULL)
{
printf("open read file error.\n");
return 0;
}
while (feof(source) == 0)
{
if ((numr = fread(buffer, 1, 100, source)) != 100)
{
if (ferror(target) != 0)
{
printf("read file error.\n");
return 0;
}
}
fwrite(buffer, 1, numr, target);
if ((numw = fwrite(buffer, 1, numr, target)) != numr)
{
printf("write file error.\n");
return 0;
}
}
fclose(source);
fclose(target);
return 0;
}