『第
2 楼』:
自己参考网上的资料写了一个,目前运行好像没有什么错误.不知会不会有什么其它问题.请大家帮忙看下.
#include<stdio.h>
main(int argc, char *argv[])
{
FILE *fp1, *fp2;
char *buf[4096];
unsigned long long filemax;
if (argc != 3)
{
printf("err!");
exit(1);
}
if ((fp1 = fopen(argv[1], "rb")) == NULL)
{
printf("Cannot open file:%s", argv[1]);
exit(1);
}
if ((fp2 = fopen(argv[2], "wb")) == NULL)
{
printf("Cannot open file:%s", argv[2]);
exit(1);
}
fread(&filemax, 8, 1, fp1);
while (filemax > 4096)
{
fread(&buf, 4096, 1, fp1);
fwrite(&buf, 4096, 1, fp2);
filemax -= 4096;
}
fread(&buf, filemax, 1, fp1);
fwrite(&buf, filemax, 1, fp2);
fclose(fp1);fclose(fp2);
exit(0);
}
|