title: Homemade fstat to get file size, always returns 0 length
body: <p>I am trying to use my own function to get the file size from a file. I'll use this to allocate memory for a data structure to hold the information on the file.</p>
  
  <p>The file size function looks like this:</p>
  
  <pre><code>long fileSize(FILE *fp){
      long start;
      fflush(fp);
      rewind(fp);
      start = ftell(fp);
      return (fseek(fp, 0L, SEEK_END) - start);
  }
  </code></pre>
  
  <p>Any ideas what I'm doing wrong here?</p>