title: copying the contents of a binary file
body: <p>I am designing an image decoder and as a first step I tried to just copy the using c. i.e open the file, and write its contents to a new file. Below is the code that I used.</p>
  
  <pre><code>while((c=getc(fp))!=EOF)
    fprintf(fp1,"%c",c);
  </code></pre>
  
  <p>where fp is the source file and fp1 is the destination file.
  The program executes without any error, but the image file(".bmp") is not properly copied. I have observed that the size of the copied file is less and only 20% of the image is visible, all else is black. When I tried with simple text files, the copy was complete.</p>
  
  <p>Do you know what the problem is?</p>