seems to copy the header fine but where is the rest of the file? ee2.bmp is 54 bytes but the orignal file is 12,400 bytes. It should be a straight copy. meow. Tried using both rb and r+b. moved fclose to see if placement made any difference. Devcpp console .c code compiles no errors.Code:#include<stdio.h> #include<stdlib.h> /* bmp file copy test fputc fgetc */ int main(){ int a ; int b ; char ch ; char buffer; FILE *ptrout ; FILE *fp; if ((fp = fopen("example2.bmp", "r+b")) ==NULL){ printf("Error opening file\n"); exit(1); } if ((ptrout = fopen("ee2.bmp", "w+b")) ==NULL){ printf("Error opening file\n"); exit(1); } a = 0 ; while ((ch = fgetc(fp)) !=EOF) { /* buffer = ch ; */ /* fputc( buffer , ptrout); */ fputc( ch , ptrout); a = a + 1 ; } printf(" Filesize[a] = %d \n\n", a ); fclose(fp); fclose(ptrout); /* fclose(fp); moved infront of ptrout */ printf("Done...."); system("PAUSE"); return 0; }
Even when I replace EOF with SEEK_END it will read more or the next block but not the entire file. I have a win32 prog that will read and display a bmp file so I know the win32 works but not the console. It seems the console prog is has a problem reading the file. I do not know why. Any thoughts?



LinkBack URL
About LinkBacks




