title: Detect end of text file, reading using fgetc
body: <p>I have a text file. I am writing a program to read from the file using <strong>fgetc</strong> and put in a two dimensional buffer. </p>
  
  <p>After printing the contents of file, it's printing some junk until end of buffer despite having put the check for EOF and ERROR as shown below. How can I get it done?</p>
  
  <pre><code>    unsigned char ch;
      while(ch=fgetc(fp))
      {
         if(ch== EOF || ch==NULL)
         break;
         //OTHER INSTRUCTIONS
      }
  </code></pre>
  
  <p>Thanks :) </p>