I want to write a Code in C which can create copy any given file (txt, bmp, jpg, pdf etc) what i've written so far is:
int main(){
FILE *fp;
char ch;
FILE *fpW;
if((fpW = fopen("file2.gif","wb"))==NULL) {
printf("Cannot open Destination file.\n");
exit(1);
}
if((fp = fopen("file.gif","rb"))==NULL) {
printf("Cannot open Source file.\n");
exit(1);
}
while((ch = fgetc( fp )) != EOF) {
fputc(ch, fpW);
}
fclose(fp);
fclose(fpW);
//printf("\n %s \n",ret);
return 0;
}
it works fine with txt file but doesn't work with pdf and image files .... please Help ..!!