1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <stdio.h>
#include <conio.h>
#include <errno.h>
#define length 64000
void main(){
FILE *fsrc, *fdes;
long size;
char buffer[length];
clrscr();
fsrc = fopen("D:\\One.bin","rb+");
fdes = fopen("D:\\Two.bin","wb+");
fseek(fsrc,0,2);
size = ftell(fsrc);
fseek(fsrc,0,0);
printf("at %ld\n",ftell(fsrc)); // <--ftell return -1 but when i close the
// looping, ftell return 0
printf("Error : %s",strerror(errno));
while ( ftell(fsrc) < size-length ){
// while(!feof(fsrc)){ <--same error
// long result = fread(buffer,length,1,fsrc);
fread(buffer,length,1,fsrc);
fwrite(buffer,length,1,fdes);
printf("\nat %ld",ftell(fsrc));
}
fclose(fsrc);
fclose(fdes);
getch();
}
|