title: How to open an image using C?
body: <p>I have opened a <code>.txt</code> file many times using the C language's file handling facilities. But when I try to open an image file using the same procedure as for text files, I just can't do that.
  I even tried this by opening the image file in binary mode <code>"rb"</code>.</p>
  
  <p>This is the code I'm using:</p>
  
  <pre><code>#include "file.h"
  #include "stdio.h"
  
  main()
  {
      FILE *fp;
      char ch;
      fp = fopen("D:\\setups\\tcc\\Bluehills.bmp", "rb+");
  
      if(fp == NULL)
      {
          printf("Error in opening the image");
          fclose(fp);
          exit(0);
      }
  
      printf("Successfully opened the image file");
  
      while((ch = fgetc(fp)) != EOF)
      {
          printf("%c", ch);
      }
  
      printf("\nWriting to o/p completed");
  }
  </code></pre>
  
  <p>What do I need to modify to get the image as it is? As I'm directing the image output to the DOS window at least a monochrome pixel image must come up.</p>