title: fseek on a position beyond EOF does not trigger EOF using feof, how come?
body: <p>I'm reading data from a file to memory that is opened with:</p>
  
  <pre><code>FILE *f = fopen(path, "rb");
  </code></pre>
  
  <p>Before I start copying bytes from the file I seek to a start position using: </p>
  
  <pre><code>/**                                                                                                                                                    
   * Goes to the given position of the given file.                                                                                                       
   *                                                                                                                                                     
   * - Returns 0 on success                                                                                                                              
   * - Returns -1 on EOF                                                                                                                                 
   * - Returns -2 if an error occured, see errno for error code                                                                                          
   * - Returns -3 if none of the above applies. This should never happen!                                                                                
   */                                                                                                                                                    
  
  static int8_t goto_pos(FILE *f, uint64_t pos)                                                                                                          
  {                                                                                                                                                      
          int err = fseek(f, pos, SEEK_SET);                                                                                                             
  
          if (err != 0) {                                                                                                                                
                  if (feof(f) != 0) return -1;                                                                                                           
                  if (ferror(f) != 0) return -2;                                                                                                         
                  return -3;                                                                                                                             
          }                                                                                                                                              
  
          return 0;                                                                                                                                      
  }
  </code></pre>
  
  <p><strong>The problem is that even though I seek to a position way beyond <code>EOF</code>, this function never returns -1.</strong></p>
  
  <p>According to the reference <code>feof</code> should return a non zero value when <code>EOF</code> is encountered.</p>
  
  <p>Why is this? Is the <code>feof</code> function useless?</p>
  
  <hr>
  
  <p>Note that I'm currently using the return value of <code>fgetc</code> to check for <code>EOF</code>.</p>