I have this problem with my code, I can transfer text files from one directory to another directory. But when i change the file name to a jpeg file, the program just refuse to transfer my picture... I really cannot understand why? Can anyone help please? Thanks!
Code:
#include <stdio.h>
int main()
{
int i,j;
int success;
char buffer;
char *pbuffer = &buffer;
FILE *source_fptr; //file pointer
FILE *dest_fptr;
source_fptr = fopen("../a/drama.jpg", "r");
if (source_fptr == NULL)
{
fprintf(stderr,"Error - Cannot open the source file\n");
exit(1); //exits the program
}
dest_fptr = fopen("../b/copied_drama.jpg", "w");
if (dest_fptr == NULL)
{
fprintf(stderr,"Error - Cannot open the destination file\n");
exit(1); //exits the program
}
i=0;
while(1)
{
fread(pbuffer, 1, 1, source_fptr);
if(feof(source_fptr))
break;
fwrite(pbuffer,1, 1, dest_fptr);
if(feof(source_fptr))
break;
i++;
}
//printf("\nThe number of loop iterations: %i\n", i);
fclose(source_fptr);
fclose(dest_fptr);
return 0;
}